1
+ import {
2
+ ModuleDetectionKind ,
3
+ ModuleKind ,
4
+ ModuleResolutionKind ,
5
+ } from "../../_namespaces/ts.js" ;
1
6
import * as Utils from "../../_namespaces/Utils.js" ;
2
7
import { jsonToReadableText } from "../helpers.js" ;
3
8
import {
@@ -6,6 +11,7 @@ import {
6
11
getFsContentsForAlternateResultDts ,
7
12
getFsContentsForAlternateResultPackageJson ,
8
13
} from "../helpers/alternateResult.js" ;
14
+ import { compilerOptionsToConfigJson } from "../helpers/contents.js" ;
9
15
import { verifyTscWatch } from "../helpers/tscWatch.js" ;
10
16
import {
11
17
createWatchedSystem ,
@@ -712,4 +718,69 @@ describe("unittests:: tsc-watch:: moduleResolution::", () => {
712
718
} ,
713
719
] ,
714
720
} ) ;
721
+
722
+ verifyTscWatch ( {
723
+ scenario : "moduleResolution" ,
724
+ subScenario : "type reference resolutions with impliedMode" ,
725
+ sys : ( ) =>
726
+ createWatchedSystem ( {
727
+ "/user/username/projects/myproject/package.json" : jsonToReadableText ( {
728
+ name : "myproject" ,
729
+ version : "1.0.0" ,
730
+ type : "module" ,
731
+ } ) ,
732
+ "/user/username/projects/myproject/tsconfig.json" : jsonToReadableText ( {
733
+ compilerOptions : compilerOptionsToConfigJson ( {
734
+ moduleResolution : ModuleResolutionKind . Node16 ,
735
+ module : ModuleKind . Node16 ,
736
+ moduleDetection : ModuleDetectionKind . Legacy ,
737
+ types : [ ] ,
738
+ } ) ,
739
+ } ) ,
740
+ "/user/username/projects/myproject/index.ts" : Utils . dedent `
741
+ /// <reference types="pkg"/>
742
+ interface LocalInterface extends RequireInterface {}
743
+ ` ,
744
+ "/user/username/projects/myproject/node_modules/@types/pkg/package.json" : jsonToReadableText ( {
745
+ name : "pkg" ,
746
+ version : "0.0.1" ,
747
+ exports : {
748
+ import : "./import.js" ,
749
+ require : "./require.js" ,
750
+ } ,
751
+ } ) ,
752
+ "/user/username/projects/myproject/node_modules/@types/pkg/import.d.ts" : Utils . dedent `
753
+ export {};
754
+ declare global {
755
+ interface ImportInterface {}
756
+ }
757
+ ` ,
758
+ "/user/username/projects/myproject/node_modules/@types/pkg/require.d.ts" : Utils . dedent `
759
+ export {};
760
+ declare global {
761
+ interface RequireInterface {}
762
+ }
763
+ ` ,
764
+ [ libFile . path ] : libFile . content ,
765
+ [ "/a/lib/lib.es2022.full.d.ts" ] : libFile . content ,
766
+ } , { currentDirectory : "/user/username/projects/myproject" } ) ,
767
+ commandLineArgs : [ "-w" , "--traceResolution" , "--explainFiles" ] ,
768
+ edits : [
769
+ {
770
+ caption : "Modify package json" ,
771
+ edit : sys =>
772
+ sys . prependFile (
773
+ "/user/username/projects/myproject/package.json" ,
774
+ jsonToReadableText ( {
775
+ name : "myproject" ,
776
+ version : "1.0.0" ,
777
+ } ) ,
778
+ ) ,
779
+ timeouts : sys => {
780
+ sys . runQueuedTimeoutCallbacks ( ) ;
781
+ sys . runQueuedTimeoutCallbacks ( ) ;
782
+ } ,
783
+ } ,
784
+ ] ,
785
+ } ) ;
715
786
} ) ;
0 commit comments