1
+ namespace ts {
2
+ // https://github.com/microsoft/TypeScript/issues/31696
3
+ it ( "unittests:: tsbuild:: synthesized module specifiers to referenced projects resolve correctly" , ( ) => {
4
+ const fs = vfs . createFromFileSystem ( Harness . IO , /*ignoreCase*/ false , {
5
+ files : {
6
+ "/src/common/nominal.ts" : "export declare type Nominal<T, Name extends string> = T & {\n\t[Symbol.species]: Name;\n};\n" ,
7
+ "/src/common/tsconfig.json" : JSON . stringify ( {
8
+ extends : "../../tsconfig.base.json" ,
9
+ compilerOptions : { composite : true } ,
10
+ include : [ "nominal.ts" ]
11
+ } ) ,
12
+ "/src/sub-project/index.ts" : "import { Nominal } from '../common/nominal';\n\nexport type MyNominal = Nominal<string, 'MyNominal'>;\n" ,
13
+ "/src/sub-project/tsconfig.json" : JSON . stringify ( {
14
+ extends : "../../tsconfig.base.json" ,
15
+ compilerOptions : { composite : true } ,
16
+ references : [ { path : "../common" } ] ,
17
+ include : [ "./index.ts" ]
18
+ } ) ,
19
+ "/src/sub-project-2/index.ts" :
20
+ "import { MyNominal } from '../sub-project/index';\n\n" +
21
+ "const variable = {\n\tkey: 'value' as MyNominal,\n};\n\n" +
22
+ "export function getVar(): keyof typeof variable {\n\treturn 'key';\n}\n" ,
23
+ "/src/sub-project-2/tsconfig.json" : JSON . stringify ( {
24
+ extends : "../../tsconfig.base.json" ,
25
+ compilerOptions : { composite : true } ,
26
+ references : [ { path : "../sub-project" } ] ,
27
+ include : [ "./index.ts" ]
28
+ } ) ,
29
+ "/src/tsconfig.json" : JSON . stringify ( {
30
+ compilerOptions : { composite : true } ,
31
+ references : [ { path : "./sub-project" } , { path : "./sub-project-2" } ] ,
32
+ include : [ ]
33
+ } ) ,
34
+ "/tsconfig.base.json" : JSON . stringify ( {
35
+ compilerOptions : {
36
+ rootDir : "./" ,
37
+ outDir : "lib" ,
38
+ lib : [ "dom" , "es2015" , "es2015.symbol.wellknown" ]
39
+ } ,
40
+ } ) ,
41
+ "/tsconfig.json" : JSON . stringify ( {
42
+ compilerOptions : { composite : true } ,
43
+ references : [ { path : "./src" } ] ,
44
+ include : [ ]
45
+ } )
46
+ } ,
47
+ cwd : "/"
48
+ } ) ;
49
+ const sys = new fakes . System ( fs , { executingFilePath : "/" , newLine : "\n" } ) ;
50
+ const host = new fakes . SolutionBuilderHost ( sys ) ;
51
+ const builder = createSolutionBuilder ( host , [ "/tsconfig.json" ] , { dry : false , force : false , verbose : false } ) ;
52
+ builder . build ( "/tsconfig.json" ) ;
53
+
54
+ const data = host . vfs . readFileSync ( '/lib/src/sub-project-2/index.d.ts' , "utf8" ) ;
55
+
56
+ // Prior to fixing GH31696 the import below was `import("../../lib/src/common/nonterminal")`
57
+ assert . equal ( data , `declare const variable: {\n key: import("../common/nominal").Nominal<string, "MyNominal">;\n};\nexport declare function getVar(): keyof typeof variable;\nexport {};\n` ) ;
58
+ } ) ;
59
+ }
0 commit comments