@@ -1113,6 +1113,34 @@ namespace ts.tscWatch {
1113
1113
checkProgramActualFiles ( watch ( ) , files . map ( file => file . path ) ) ;
1114
1114
checkOutputErrors ( host , [ ] , ExpectedOutputErrorsPosition . AfterFileChangeDetected ) ;
1115
1115
} ) ;
1116
+
1117
+ it ( "watched files when file is deleted and new file is added as part of change" , ( ) => {
1118
+ const projectLocation = "/home/username/project" ;
1119
+ const file : FileOrFolder = {
1120
+ path : `${ projectLocation } /src/file1.ts` ,
1121
+ content : "var a = 10;"
1122
+ } ;
1123
+ const configFile : FileOrFolder = {
1124
+ path : `${ projectLocation } /tsconfig.json` ,
1125
+ content : "{}"
1126
+ } ;
1127
+ const files = [ file , libFile , configFile ] ;
1128
+ const host = createWatchedSystem ( files ) ;
1129
+ const watch = createWatchOfConfigFile ( configFile . path , host ) ;
1130
+ verifyProgram ( ) ;
1131
+
1132
+ file . path = file . path . replace ( "file1" , "file2" ) ;
1133
+ host . reloadFS ( files ) ;
1134
+ host . runQueuedTimeoutCallbacks ( ) ;
1135
+ verifyProgram ( ) ;
1136
+
1137
+ function verifyProgram ( ) {
1138
+ checkProgramActualFiles ( watch ( ) , mapDefined ( files , f => f === configFile ? undefined : f . path ) ) ;
1139
+ checkWatchedDirectories ( host , [ ] , /*recursive*/ false ) ;
1140
+ checkWatchedDirectories ( host , [ projectLocation , `${ projectLocation } /node_modules/@types` ] , /*recursive*/ true ) ;
1141
+ checkWatchedFiles ( host , files . map ( f => f . path ) ) ;
1142
+ }
1143
+ } ) ;
1116
1144
} ) ;
1117
1145
1118
1146
describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
0 commit comments