@@ -15,6 +15,10 @@ namespace ts.server {
1515 createHash ( algorithm : string ) : Hash
1616 } = require ( "crypto" ) ;
1717
18+ export function shouldEmitFile ( scriptInfo : ScriptInfo ) {
19+ return ! scriptInfo . hasMixedContent ;
20+ }
21+
1822 /**
1923 * An abstract file info that maintains a shape signature.
2024 */
@@ -160,16 +164,17 @@ namespace ts.server {
160164 */
161165 getFilesAffectedBy ( scriptInfo : ScriptInfo ) : string [ ] {
162166 const info = this . getOrCreateFileInfo ( scriptInfo . path ) ;
167+ const singleFileResult = scriptInfo . hasMixedContent ? [ ] : [ scriptInfo . fileName ] ;
163168 if ( info . updateShapeSignature ( ) ) {
164169 const options = this . project . getCompilerOptions ( ) ;
165170 // If `--out` or `--outFile` is specified, any new emit will result in re-emitting the entire project,
166171 // so returning the file itself is good enough.
167172 if ( options && ( options . out || options . outFile ) ) {
168- return [ scriptInfo . fileName ] ;
173+ return singleFileResult ;
169174 }
170- return this . project . getFileNamesWithoutDefaultLib ( ) ;
175+ return this . project . getAllEmittableFiles ( ) ;
171176 }
172- return [ scriptInfo . fileName ] ;
177+ return singleFileResult ;
173178 }
174179 }
175180
@@ -319,18 +324,19 @@ namespace ts.server {
319324 getFilesAffectedBy ( scriptInfo : ScriptInfo ) : string [ ] {
320325 this . ensureProjectDependencyGraphUpToDate ( ) ;
321326
327+ const singleFileResult = scriptInfo . hasMixedContent ? [ ] : [ scriptInfo . fileName ] ;
322328 const fileInfo = this . getFileInfo ( scriptInfo . path ) ;
323329 if ( ! fileInfo || ! fileInfo . updateShapeSignature ( ) ) {
324- return [ scriptInfo . fileName ] ;
330+ return singleFileResult ;
325331 }
326332
327333 if ( ! fileInfo . isExternalModuleOrHasOnlyAmbientExternalModules ( ) ) {
328- return this . project . getFileNamesWithoutDefaultLib ( ) ;
334+ return this . project . getAllEmittableFiles ( ) ;
329335 }
330336
331337 const options = this . project . getCompilerOptions ( ) ;
332338 if ( options && ( options . isolatedModules || options . out || options . outFile ) ) {
333- return [ scriptInfo . fileName ] ;
339+ return singleFileResult ;
334340 }
335341
336342 // Now we need to if each file in the referencedBy list has a shape change as well.
@@ -339,8 +345,8 @@ namespace ts.server {
339345
340346 // Use slice to clone the array to avoid manipulating in place
341347 const queue = fileInfo . referencedBy . slice ( 0 ) ;
342- const fileNameSet = createMap < boolean > ( ) ;
343- fileNameSet [ scriptInfo . fileName ] = true ;
348+ const fileNameSet = createMap < ScriptInfo > ( ) ;
349+ fileNameSet [ scriptInfo . fileName ] = scriptInfo ;
344350 while ( queue . length > 0 ) {
345351 const processingFileInfo = queue . pop ( ) ;
346352 if ( processingFileInfo . updateShapeSignature ( ) && processingFileInfo . referencedBy . length > 0 ) {
@@ -350,9 +356,15 @@ namespace ts.server {
350356 }
351357 }
352358 }
353- fileNameSet [ processingFileInfo . scriptInfo . fileName ] = true ;
359+ fileNameSet [ processingFileInfo . scriptInfo . fileName ] = processingFileInfo . scriptInfo ;
360+ }
361+ const result : string [ ] = [ ] ;
362+ for ( const fileName in fileNameSet ) {
363+ if ( shouldEmitFile ( fileNameSet [ fileName ] ) ) {
364+ result . push ( fileName ) ;
365+ }
354366 }
355- return Object . keys ( fileNameSet ) ;
367+ return result ;
356368 }
357369 }
358370
0 commit comments