@@ -34,6 +34,10 @@ namespace ts.tscWatch {
3434 return `${ projectPath ( subProject ) } /${ baseFileName . toLowerCase ( ) } ` ;
3535 }
3636
37+ function projectFileName ( subProject : SubProject , baseFileName : string ) {
38+ return `${ projectPath ( subProject ) } /${ baseFileName } ` ;
39+ }
40+
3741 function projectFile ( subProject : SubProject , baseFileName : string ) : File {
3842 return {
3943 path : projectFilePath ( subProject , baseFileName ) ,
@@ -391,10 +395,10 @@ let x: string = 10;`);
391395 } ) ;
392396
393397 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 ( ) ) ) ;
398402 const expectedWatchedDirectoriesRecursive = projectSystem . getTypeRootsFromLocation ( projectPath ( SubProject . tests ) ) ;
399403
400404 function createSolution ( ) {
@@ -432,7 +436,7 @@ let x: string = 10;`);
432436 }
433437
434438 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 ) ;
436440 }
437441
438442 describe ( "invoking when references are already built" , ( ) => {
@@ -447,7 +451,7 @@ let x: string = 10;`);
447451 } ) ;
448452
449453 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 ( ) ;
451455 host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
452456function foo() {
453457}` ) ;
@@ -456,10 +460,11 @@ function foo() {
456460
457461 host . checkTimeoutQueueLengthAndRun ( 1 ) ; // not ideal, but currently because of d.ts but no new file is written
458462 checkOutputErrorsIncremental ( host , emptyArray ) ;
463+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , [ tests [ 1 ] . path , libFile . path , coreIndexDts , coreAnotherModuleDts , logicIndexDts ] ) ;
459464 } ) ;
460465
461466 it ( "non local edit in ts file, rebuilds in watch compilation" , ( ) => {
462- const { host, solutionBuilder } = createSolutionAndWatchMode ( ) ;
467+ const { host, solutionBuilder, watch } = createSolutionAndWatchMode ( ) ;
463468 host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
464469export function gfoo() {
465470}` ) ;
@@ -468,8 +473,26 @@ export function gfoo() {
468473
469474 host . checkTimeoutQueueLengthAndRun ( 1 ) ;
470475 checkOutputErrorsIncremental ( host , emptyArray ) ;
476+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , [ tests [ 1 ] . path , libFile . path , coreIndexDts , coreAnotherModuleDts , logicIndexDts ] ) ;
471477 } ) ;
472478
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+ } ) ;
473496 } ) ;
474497 } ) ;
475498 } ) ;
0 commit comments