@@ -34,6 +34,10 @@ namespace ts.tscWatch {
34
34
return `${ projectPath ( subProject ) } /${ baseFileName . toLowerCase ( ) } ` ;
35
35
}
36
36
37
+ function projectFileName ( subProject : SubProject , baseFileName : string ) {
38
+ return `${ projectPath ( subProject ) } /${ baseFileName } ` ;
39
+ }
40
+
37
41
function projectFile ( subProject : SubProject , baseFileName : string ) : File {
38
42
return {
39
43
path : projectFilePath ( subProject , baseFileName ) ,
@@ -391,10 +395,10 @@ let x: string = 10;`);
391
395
} ) ;
392
396
393
397
describe ( "tsc-watch works with project references" , ( ) => {
394
- const coreIndexDts = projectFilePath ( SubProject . core , "index.d.ts" ) ;
395
- const coreAnotherModuleDts = projectFilePath ( SubProject . core , "anotherModule.d.ts" ) ;
396
- const logicIndexDts = projectFilePath ( SubProject . logic , "index.d.ts" ) ;
397
- const expectedWatchedFiles = [ core [ 0 ] , logic [ 0 ] , ...tests , libFile ] . map ( f => f . path ) . concat ( coreIndexDts , coreAnotherModuleDts , logicIndexDts ) ;
398
+ const coreIndexDts = projectFileName ( SubProject . core , "index.d.ts" ) ;
399
+ const coreAnotherModuleDts = projectFileName ( SubProject . core , "anotherModule.d.ts" ) ;
400
+ const logicIndexDts = projectFileName ( SubProject . logic , "index.d.ts" ) ;
401
+ const expectedWatchedFiles = [ core [ 0 ] , logic [ 0 ] , ...tests , libFile ] . map ( f => f . path ) . concat ( [ coreIndexDts , coreAnotherModuleDts , logicIndexDts ] . map ( f => f . toLowerCase ( ) ) ) ;
398
402
const expectedWatchedDirectoriesRecursive = projectSystem . getTypeRootsFromLocation ( projectPath ( SubProject . tests ) ) ;
399
403
400
404
function createSolution ( ) {
@@ -432,7 +436,7 @@ let x: string = 10;`);
432
436
}
433
437
434
438
function verifyDependencies ( watch : ( ) => BuilderProgram , filePath : string , expected : ReadonlyArray < string > ) {
435
- checkArray ( `${ filePath } dependencies` , watch ( ) . getAllDependencies ( watch ( ) . getSourceFile ( filePath ) ! ) . map ( f => f . toLocaleLowerCase ( ) ) , expected ) ;
439
+ checkArray ( `${ filePath } dependencies` , watch ( ) . getAllDependencies ( watch ( ) . getSourceFile ( filePath ) ! ) , expected ) ;
436
440
}
437
441
438
442
describe ( "invoking when references are already built" , ( ) => {
@@ -447,7 +451,7 @@ let x: string = 10;`);
447
451
} ) ;
448
452
449
453
it ( "local edit in ts file, result in watch compilation because logic.d.ts is written" , ( ) => {
450
- const { host, solutionBuilder } = createSolutionAndWatchMode ( ) ;
454
+ const { host, solutionBuilder, watch } = createSolutionAndWatchMode ( ) ;
451
455
host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
452
456
function foo() {
453
457
}` ) ;
@@ -456,10 +460,11 @@ function foo() {
456
460
457
461
host . checkTimeoutQueueLengthAndRun ( 1 ) ; // not ideal, but currently because of d.ts but no new file is written
458
462
checkOutputErrorsIncremental ( host , emptyArray ) ;
463
+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , [ tests [ 1 ] . path , libFile . path , coreIndexDts , coreAnotherModuleDts , logicIndexDts ] ) ;
459
464
} ) ;
460
465
461
466
it ( "non local edit in ts file, rebuilds in watch compilation" , ( ) => {
462
- const { host, solutionBuilder } = createSolutionAndWatchMode ( ) ;
467
+ const { host, solutionBuilder, watch } = createSolutionAndWatchMode ( ) ;
463
468
host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
464
469
export function gfoo() {
465
470
}` ) ;
@@ -468,8 +473,26 @@ export function gfoo() {
468
473
469
474
host . checkTimeoutQueueLengthAndRun ( 1 ) ;
470
475
checkOutputErrorsIncremental ( host , emptyArray ) ;
476
+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , [ tests [ 1 ] . path , libFile . path , coreIndexDts , coreAnotherModuleDts , logicIndexDts ] ) ;
471
477
} ) ;
472
478
479
+ it ( "change in project reference config file builds correctly" , ( ) => {
480
+ const { host, solutionBuilder, watch } = createSolutionAndWatchMode ( ) ;
481
+ host . writeFile ( logic [ 0 ] . path , JSON . stringify ( {
482
+ compilerOptions : { composite : true , declaration : true , declarationDir : "decls" } ,
483
+ references : [ { path : "../core" } ]
484
+ } ) ) ;
485
+ solutionBuilder . invalidateProject ( logic [ 0 ] . path , ConfigFileProgramReloadLevel . Full ) ;
486
+ solutionBuilder . buildInvalidatedProject ( ) ;
487
+
488
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ;
489
+ checkOutputErrorsIncremental ( host , [
490
+ // TODO: #26036
491
+ // The error is reported in d.ts file because it isnt resolved from ts file path, but is resolved from .d.ts file
492
+ "sample1/logic/decls/index.d.ts(2,22): error TS2307: Cannot find module '../core/anotherModule'.\n"
493
+ ] ) ;
494
+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , [ tests [ 1 ] . path , libFile . path , coreIndexDts , coreAnotherModuleDts , projectFilePath ( SubProject . logic , "decls/index.d.ts" ) ] ) ;
495
+ } ) ;
473
496
} ) ;
474
497
} ) ;
475
498
} ) ;
0 commit comments