@@ -30,8 +30,9 @@ namespace ts.tscWatch {
30
30
return ts . parseConfigFile ( configFileName , { } , watchingSystemHost . system , watchingSystemHost . reportDiagnostic , watchingSystemHost . reportWatchDiagnostic ) ;
31
31
}
32
32
33
- function createWatchModeWithConfigFile ( configFilePath : string , host : WatchedSystem ) {
33
+ function createWatchModeWithConfigFile ( configFilePath : string , host : WatchedSystem , maxNumberOfFilesToIterateForInvalidation ?: number ) {
34
34
const watchingSystemHost = createWatchingSystemHost ( host ) ;
35
+ watchingSystemHost . maxNumberOfFilesToIterateForInvalidation = maxNumberOfFilesToIterateForInvalidation ;
35
36
const configFileResult = parseConfigFile ( configFilePath , watchingSystemHost ) ;
36
37
return ts . createWatchModeWithConfigFile ( configFileResult , { } , watchingSystemHost ) ;
37
38
}
@@ -1067,6 +1068,36 @@ namespace ts.tscWatch {
1067
1068
assert . equal ( nowErrors [ 0 ] . start , intialErrors [ 0 ] . start - configFileContentComment . length ) ;
1068
1069
assert . equal ( nowErrors [ 1 ] . start , intialErrors [ 1 ] . start - configFileContentComment . length ) ;
1069
1070
} ) ;
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
+ } ) ;
1070
1101
} ) ;
1071
1102
1072
1103
describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
0 commit comments