@@ -30,8 +30,9 @@ namespace ts.tscWatch {
3030 return ts . parseConfigFile ( configFileName , { } , watchingSystemHost . system , watchingSystemHost . reportDiagnostic , watchingSystemHost . reportWatchDiagnostic ) ;
3131 }
3232
33- function createWatchModeWithConfigFile ( configFilePath : string , host : WatchedSystem ) {
33+ function createWatchModeWithConfigFile ( configFilePath : string , host : WatchedSystem , maxNumberOfFilesToIterateForInvalidation ?: number ) {
3434 const watchingSystemHost = createWatchingSystemHost ( host ) ;
35+ watchingSystemHost . maxNumberOfFilesToIterateForInvalidation = maxNumberOfFilesToIterateForInvalidation ;
3536 const configFileResult = parseConfigFile ( configFilePath , watchingSystemHost ) ;
3637 return ts . createWatchModeWithConfigFile ( configFileResult , { } , watchingSystemHost ) ;
3738 }
@@ -1067,6 +1068,36 @@ namespace ts.tscWatch {
10671068 assert . equal ( nowErrors [ 0 ] . start , intialErrors [ 0 ] . start - configFileContentComment . length ) ;
10681069 assert . equal ( nowErrors [ 1 ] . start , intialErrors [ 1 ] . start - configFileContentComment . length ) ;
10691070 } ) ;
1071+
1072+ it ( "should not trigger recompilation because of program emit" , ( ) => {
1073+ const proj = "/user/username/projects/myproject" ;
1074+ const file1 : FileOrFolder = {
1075+ path : `${ proj } /file1.ts` ,
1076+ content : "export const c = 30;"
1077+ } ;
1078+ const file2 : FileOrFolder = {
1079+ path : `${ proj } /src/file2.ts` ,
1080+ content : `import {c} from "file1"; export const d = 30;`
1081+ } ;
1082+ const tsconfig : FileOrFolder = {
1083+ path : `${ proj } /tsconfig.json` ,
1084+ content : JSON . stringify ( {
1085+ compilerOptions : {
1086+ module : "amd" ,
1087+ outDir : "build"
1088+ }
1089+ } )
1090+ } ;
1091+ const host = createWatchedSystem ( [ file1 , file2 , libFile , tsconfig ] , { currentDirectory : proj } ) ;
1092+ const watch = createWatchModeWithConfigFile ( tsconfig . path , host , /*maxNumberOfFilesToIterateForInvalidation*/ 1 ) ;
1093+ checkProgramActualFiles ( watch ( ) , [ file1 . path , file2 . path , libFile . path ] ) ;
1094+
1095+ assert . isTrue ( host . fileExists ( "build/file1.js" ) ) ;
1096+ assert . isTrue ( host . fileExists ( "build/src/file2.js" ) ) ;
1097+
1098+ // This should be 0
1099+ host . checkTimeoutQueueLengthAndRun ( 0 ) ;
1100+ } ) ;
10701101 } ) ;
10711102
10721103 describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
0 commit comments