@@ -3181,7 +3181,7 @@ namespace ts.projectSystem {
3181
3181
const projectLocation = "/user/username/projects/project" ;
3182
3182
const file1 : FileOrFolder = {
3183
3183
path : `${ projectLocation } /src/file1.ts` ,
3184
- content : `import { y } from "./file1 "; let x = 10;`
3184
+ content : `import { y } from "./file2 "; let x = 10;`
3185
3185
} ;
3186
3186
const file2 : FileOrFolder = {
3187
3187
path : `${ projectLocation } /src/file2.ts` ,
@@ -3217,6 +3217,53 @@ namespace ts.projectSystem {
3217
3217
} ) ;
3218
3218
3219
3219
} ) ;
3220
+
3221
+ it ( "Orphan source files are handled correctly on watch trigger" , ( ) => {
3222
+ const projectLocation = "/user/username/projects/project" ;
3223
+ const file1 : FileOrFolder = {
3224
+ path : `${ projectLocation } /src/file1.ts` ,
3225
+ content : `export let x = 10;`
3226
+ } ;
3227
+ const file2 : FileOrFolder = {
3228
+ path : `${ projectLocation } /src/file2.ts` ,
3229
+ content : "export let y = 10;"
3230
+ } ;
3231
+ const configContent1 = JSON . stringify ( {
3232
+ files : [ "src/file1.ts" , "src/file2.ts" ]
3233
+ } ) ;
3234
+ const config : FileOrFolder = {
3235
+ path : `${ projectLocation } /tsconfig.json` ,
3236
+ content : configContent1
3237
+ } ;
3238
+ const files = [ file1 , file2 , libFile , config ] ;
3239
+ const host = createServerHost ( files ) ;
3240
+ const service = createProjectService ( host ) ;
3241
+ service . openClientFile ( file1 . path ) ;
3242
+ checkProjectActualFiles ( service . configuredProjects . get ( config . path ) , [ file1 . path , file2 . path , libFile . path , config . path ] ) ;
3243
+
3244
+ const configContent2 = JSON . stringify ( {
3245
+ files : [ "src/file1.ts" ]
3246
+ } ) ;
3247
+ config . content = configContent2 ;
3248
+ host . reloadFS ( files ) ;
3249
+ host . runQueuedTimeoutCallbacks ( ) ;
3250
+
3251
+ checkProjectActualFiles ( service . configuredProjects . get ( config . path ) , [ file1 . path , libFile . path , config . path ] ) ;
3252
+ verifyFile2InfoIsOrphan ( ) ;
3253
+
3254
+ file2 . content += "export let z = 10;" ;
3255
+ host . reloadFS ( files ) ;
3256
+ host . runQueuedTimeoutCallbacks ( ) ;
3257
+
3258
+ checkProjectActualFiles ( service . configuredProjects . get ( config . path ) , [ file1 . path , libFile . path , config . path ] ) ;
3259
+ verifyFile2InfoIsOrphan ( ) ;
3260
+
3261
+ function verifyFile2InfoIsOrphan ( ) {
3262
+ const info = service . getScriptInfoForPath ( file2 . path as Path ) ;
3263
+ assert . isDefined ( info ) ;
3264
+ assert . equal ( info . containingProjects . length , 0 ) ;
3265
+ }
3266
+ } ) ;
3220
3267
} ) ;
3221
3268
3222
3269
describe ( "tsserverProjectSystem Proper errors" , ( ) => {
0 commit comments