@@ -638,6 +638,29 @@ export function gfoo() {
638
638
} : fileFromDisk ;
639
639
}
640
640
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
+
641
664
function getTsConfigFile ( multiFolder : boolean , fileFromDisk : File , folder : string ) : File {
642
665
if ( ! multiFolder ) return fileFromDisk ;
643
666
@@ -703,14 +726,6 @@ export function gfoo() {
703
726
[ cTs . path , [ cTs . path , refs . path , bDts ] ]
704
727
] ;
705
728
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
-
714
729
function createSolutionAndWatchMode ( ) {
715
730
return createSolutionAndWatchModeOfProject ( allFiles , getProjectPath ( project ) , configToBuild , configToBuild , getOutputFileStamps ) ;
716
731
}
@@ -724,21 +739,7 @@ export function gfoo() {
724
739
}
725
740
726
741
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 ) ;
742
743
}
743
744
744
745
function verifyProject ( host : WatchedSystem , service : projectSystem . TestProjectService , orphanInfos ?: ReadonlyArray < string > ) {
@@ -782,7 +783,7 @@ export function gfoo() {
782
783
783
784
host . checkTimeoutQueueLengthAndRun ( 1 ) ;
784
785
checkOutputErrorsIncremental ( host , expectedEditErrors ) ;
785
- verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , dependencies ) ;
786
+ verifyWatchState ( host , watch , expectedProgramFiles , expectedWatchedFiles , expectedWatchedDirectoriesRecursive , dependencies , expectedWatchedDirectories ) ;
786
787
787
788
if ( revert ) {
788
789
revert ( host ) ;
@@ -961,6 +962,42 @@ export function gfoo() {
961
962
962
963
describe ( "when config files are side by side" , ( ) => {
963
964
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
+ } ) ;
964
1001
} ) ;
965
1002
describe ( "when config files are in side by side folders" , ( ) => {
966
1003
verifyTransitiveReferences ( /*multiFolder*/ true ) ;
0 commit comments