@@ -638,6 +638,29 @@ export function gfoo() {
638638 } : fileFromDisk ;
639639 }
640640
641+ function dtsFile ( extensionLessFile : string ) {
642+ return getFilePathInProject ( project , `${ extensionLessFile } .d.ts` ) ;
643+ }
644+
645+ function jsFile ( extensionLessFile : string ) {
646+ return getFilePathInProject ( project , `${ extensionLessFile } .js` ) ;
647+ }
648+
649+ function verifyWatchState (
650+ host : WatchedSystem ,
651+ watch : Watch ,
652+ expectedProgramFiles : ReadonlyArray < string > ,
653+ expectedWatchedFiles : ReadonlyArray < string > ,
654+ expectedWatchedDirectoriesRecursive : ReadonlyArray < string > ,
655+ dependencies : ReadonlyArray < [ string , ReadonlyArray < string > ] > ,
656+ expectedWatchedDirectories ?: ReadonlyArray < string > ) {
657+ checkProgramActualFiles ( watch ( ) . getProgram ( ) , expectedProgramFiles ) ;
658+ verifyWatchesOfProject ( host , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , expectedWatchedDirectories ) ;
659+ for ( const [ file , deps ] of dependencies ) {
660+ verifyDependencies ( watch , file , deps ) ;
661+ }
662+ }
663+
641664 function getTsConfigFile ( multiFolder : boolean , fileFromDisk : File , folder : string ) : File {
642665 if ( ! multiFolder ) return fileFromDisk ;
643666
@@ -703,14 +726,6 @@ export function gfoo() {
703726 [ cTs . path , [ cTs . path , refs . path , bDts ] ]
704727 ] ;
705728
706- function jsFile ( extensionLessFile : string ) {
707- return getFilePathInProject ( project , `${ extensionLessFile } .js` ) ;
708- }
709-
710- function dtsFile ( extensionLessFile : string ) {
711- return getFilePathInProject ( project , `${ extensionLessFile } .d.ts` ) ;
712- }
713-
714729 function createSolutionAndWatchMode ( ) {
715730 return createSolutionAndWatchModeOfProject ( allFiles , getProjectPath ( project ) , configToBuild , configToBuild , getOutputFileStamps ) ;
716731 }
@@ -724,21 +739,7 @@ export function gfoo() {
724739 }
725740
726741 function verifyProgram ( host : WatchedSystem , watch : Watch ) {
727- verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , defaultDependencies ) ;
728- }
729-
730- function verifyWatchState (
731- host : WatchedSystem ,
732- watch : Watch ,
733- expectedProgramFiles : ReadonlyArray < string > ,
734- expectedWatchedFiles : ReadonlyArray < string > ,
735- expectedWatchedDirectoriesRecursive : ReadonlyArray < string > ,
736- dependencies : ReadonlyArray < [ string , ReadonlyArray < string > ] > ) {
737- checkProgramActualFiles ( watch ( ) . getProgram ( ) , expectedProgramFiles ) ;
738- verifyWatchesOfProject ( host , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , expectedWatchedDirectories ) ;
739- for ( const [ file , deps ] of dependencies ) {
740- verifyDependencies ( watch , file , deps ) ;
741- }
742+ verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , defaultDependencies , expectedWatchedDirectories ) ;
742743 }
743744
744745 function verifyProject ( host : WatchedSystem , service : projectSystem . TestProjectService , orphanInfos ?: ReadonlyArray < string > ) {
@@ -782,7 +783,7 @@ export function gfoo() {
782783
783784 host . checkTimeoutQueueLengthAndRun ( 1 ) ;
784785 checkOutputErrorsIncremental ( host , expectedEditErrors ) ;
785- verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , dependencies ) ;
786+ verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , dependencies , expectedWatchedDirectories ) ;
786787
787788 if ( revert ) {
788789 revert ( host ) ;
@@ -961,6 +962,42 @@ export function gfoo() {
961962
962963 describe ( "when config files are side by side" , ( ) => {
963964 verifyTransitiveReferences ( /*multiFolder*/ false ) ;
965+
966+ it ( "when referenced project uses different module resolution" , ( ) => {
967+ const bTs : File = {
968+ path : bTsFile . path ,
969+ content : `import {A} from "a";export const b = new A();`
970+ } ;
971+ const bTsconfig : File = {
972+ path : bTsconfigFile . path ,
973+ content : JSON . stringify ( {
974+ compilerOptions : { composite : true , moduleResolution : "classic" } ,
975+ files : [ "b.ts" ] ,
976+ references : [ { path : "tsconfig.a.json" } ]
977+ } )
978+ } ;
979+ const allFiles = [ libFile , aTsFile , bTs , cTsFile , aTsconfigFile , bTsconfig , cTsconfigFile , refs ] ;
980+ const aDts = dtsFile ( "a" ) , bDts = dtsFile ( "b" ) ;
981+ const expectedFiles = [ jsFile ( "a" ) , aDts , jsFile ( "b" ) , bDts , jsFile ( "c" ) ] ;
982+ const expectedProgramFiles = [ cTsFile . path , libFile . path , aDts , refs . path , bDts ] ;
983+ const expectedWatchedFiles = expectedProgramFiles . concat ( cTsconfigFile . path , bTsconfigFile . path , aTsconfigFile . path ) . map ( s => s . toLowerCase ( ) ) ;
984+ const expectedWatchedDirectoriesRecursive = [
985+ getFilePathInProject ( project , "refs" ) , // Failed lookup since refs/a.ts does not exist
986+ ...projectSystem . getTypeRootsFromLocation ( getProjectPath ( project ) )
987+ ] . map ( s => s . toLowerCase ( ) ) ;
988+
989+ const defaultDependencies : ReadonlyArray < [ string , ReadonlyArray < string > ] > = [
990+ [ aDts , [ aDts ] ] ,
991+ [ bDts , [ bDts , aDts ] ] ,
992+ [ refs . path , [ refs . path ] ] ,
993+ [ cTsFile . path , [ cTsFile . path , refs . path , bDts ] ]
994+ ] ;
995+ function getOutputFileStamps ( host : WatchedSystem ) {
996+ return expectedFiles . map ( file => [ file , host . getModifiedTime ( file ) ] as OutputFileStamp ) ;
997+ }
998+ const { host, watch } = createSolutionAndWatchModeOfProject ( allFiles , getProjectPath ( project ) , "tsconfig.c.json" , "tsconfig.c.json" , getOutputFileStamps ) ;
999+ verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , defaultDependencies ) ;
1000+ } ) ;
9641001 } ) ;
9651002 describe ( "when config files are in side by side folders" , ( ) => {
9661003 verifyTransitiveReferences ( /*multiFolder*/ true ) ;
0 commit comments