Skip to content

Commit e69d317

Browse files
committed
Test case where the wrong path is emitted
1 parent 7a5aadc commit e69d317

File tree

2 files changed

+215
-0
lines changed

2 files changed

+215
-0
lines changed

src/testRunner/unittests/tsbuild/declarationEmit.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,44 @@ declare type MyNominal<T, Name extends string> = T & {
7575
}),
7676
commandLineArgs: ["--b", "/src/solution/tsconfig.json", "--verbose"]
7777
});
78+
79+
verifyTsc({
80+
scenario: "declarationEmit",
81+
subScenario: "when declaration file used inferred type from referenced project",
82+
fs: () => loadProjectFromFiles({
83+
"/src/tsconfig.json": JSON.stringify({
84+
compilerOptions: {
85+
composite: true,
86+
baseUrl: ".",
87+
paths: { "@fluentui/*": ["packages/*/src"] }
88+
}
89+
}),
90+
"/src/packages/pkg1/src/index.ts": Utils.dedent`
91+
export interface IThing {
92+
a: string;
93+
}
94+
export interface IThings {
95+
thing1: IThing;
96+
}`,
97+
"/src/packages/pkg1/tsconfig.json": JSON.stringify({
98+
extends: "../../tsconfig",
99+
compilerOptions: { outDir: "lib" },
100+
include: ["src"]
101+
}),
102+
"/src/packages/pkg2/src/index.ts": Utils.dedent`
103+
import { IThings } from '@fluentui/pkg1';
104+
export function fn4() {
105+
const a: IThings = { thing1: { a: 'b' } };
106+
return a.thing1;
107+
}`,
108+
"/src/packages/pkg2/tsconfig.json": JSON.stringify({
109+
extends: "../../tsconfig",
110+
compilerOptions: { outDir: "lib" },
111+
include: ["src"],
112+
references: [{ path: "../pkg1" }]
113+
}),
114+
}),
115+
commandLineArgs: ["--b", "/src/packages/pkg2/tsconfig.json", "--verbose"]
116+
});
78117
});
79118
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
Input::
2+
//// [/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/src/packages/pkg1/src/index.ts]
18+
export interface IThing {
19+
a: string;
20+
}
21+
export interface IThings {
22+
thing1: IThing;
23+
}
24+
25+
//// [/src/packages/pkg1/tsconfig.json]
26+
{"extends":"../../tsconfig","compilerOptions":{"outDir":"lib"},"include":["src"]}
27+
28+
//// [/src/packages/pkg2/src/index.ts]
29+
import { IThings } from '@fluentui/pkg1';
30+
export function fn4() {
31+
const a: IThings = { thing1: { a: 'b' } };
32+
return a.thing1;
33+
}
34+
35+
//// [/src/packages/pkg2/tsconfig.json]
36+
{"extends":"../../tsconfig","compilerOptions":{"outDir":"lib"},"include":["src"],"references":[{"path":"../pkg1"}]}
37+
38+
//// [/src/tsconfig.json]
39+
{"compilerOptions":{"composite":true,"baseUrl":".","paths":{"@fluentui/*":["packages/*/src"]}}}
40+
41+
42+
43+
Output::
44+
/lib/tsc --b /src/packages/pkg2/tsconfig.json --verbose
45+
[12:00:00 AM] Projects in this build:
46+
* src/packages/pkg1/tsconfig.json
47+
* src/packages/pkg2/tsconfig.json
48+
49+
[12:00:00 AM] Project 'src/packages/pkg1/tsconfig.json' is out of date because output file 'src/packages/pkg1/lib/src/index.js' does not exist
50+
51+
[12:00:00 AM] Building project '/src/packages/pkg1/tsconfig.json'...
52+
53+
[12:00:00 AM] Project 'src/packages/pkg2/tsconfig.json' is out of date because output file 'src/packages/pkg2/lib/src/index.js' does not exist
54+
55+
[12:00:00 AM] Building project '/src/packages/pkg2/tsconfig.json'...
56+
57+
exitCode:: ExitStatus.Success
58+
59+
60+
//// [/src/packages/pkg1/lib/src/index.d.ts]
61+
export interface IThing {
62+
a: string;
63+
}
64+
export interface IThings {
65+
thing1: IThing;
66+
}
67+
68+
69+
//// [/src/packages/pkg1/lib/src/index.js]
70+
"use strict";
71+
exports.__esModule = true;
72+
73+
74+
//// [/src/packages/pkg1/lib/tsconfig.tsbuildinfo]
75+
{
76+
"program": {
77+
"fileInfos": {
78+
"../../../../lib/lib.d.ts": {
79+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
80+
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
81+
"affectsGlobalScope": true
82+
},
83+
"../src/index.ts": {
84+
"version": "-2072077482-export interface IThing {\n a: string;\n}\nexport interface IThings {\n thing1: IThing;\n}",
85+
"signature": "-5386205042-export interface IThing {\r\n a: string;\r\n}\r\nexport interface IThings {\r\n thing1: IThing;\r\n}\r\n",
86+
"affectsGlobalScope": false
87+
}
88+
},
89+
"options": {
90+
"composite": true,
91+
"baseUrl": "../../..",
92+
"paths": {
93+
"@fluentui/*": [
94+
"packages/*/src"
95+
]
96+
},
97+
"pathsBasePath": "/src",
98+
"outDir": "./",
99+
"configFilePath": "../tsconfig.json"
100+
},
101+
"referencedMap": {},
102+
"exportedModulesMap": {},
103+
"semanticDiagnosticsPerFile": [
104+
"../../../../lib/lib.d.ts",
105+
"../src/index.ts"
106+
]
107+
},
108+
"version": "FakeTSVersion"
109+
}
110+
111+
//// [/src/packages/pkg2/lib/src/index.d.ts]
112+
export declare function fn4(): import("../../pkg1/src").IThing;
113+
114+
115+
//// [/src/packages/pkg2/lib/src/index.js]
116+
"use strict";
117+
exports.__esModule = true;
118+
exports.fn4 = void 0;
119+
function fn4() {
120+
var a = { thing1: { a: 'b' } };
121+
return a.thing1;
122+
}
123+
exports.fn4 = fn4;
124+
125+
126+
//// [/src/packages/pkg2/lib/tsconfig.tsbuildinfo]
127+
{
128+
"program": {
129+
"fileInfos": {
130+
"../../../../lib/lib.d.ts": {
131+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
132+
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
133+
"affectsGlobalScope": true
134+
},
135+
"../../pkg1/lib/src/index.d.ts": {
136+
"version": "-5386205042-export interface IThing {\r\n a: string;\r\n}\r\nexport interface IThings {\r\n thing1: IThing;\r\n}\r\n",
137+
"signature": "-5386205042-export interface IThing {\r\n a: string;\r\n}\r\nexport interface IThings {\r\n thing1: IThing;\r\n}\r\n",
138+
"affectsGlobalScope": false
139+
},
140+
"../src/index.ts": {
141+
"version": "8515046367-import { IThings } from '@fluentui/pkg1';\nexport function fn4() {\n const a: IThings = { thing1: { a: 'b' } };\n return a.thing1;\n}",
142+
"signature": "-10018297277-export declare function fn4(): import(\"../../pkg1/src\").IThing;\r\n",
143+
"affectsGlobalScope": false
144+
}
145+
},
146+
"options": {
147+
"composite": true,
148+
"baseUrl": "../../..",
149+
"paths": {
150+
"@fluentui/*": [
151+
"packages/*/src"
152+
]
153+
},
154+
"pathsBasePath": "/src",
155+
"outDir": "./",
156+
"configFilePath": "../tsconfig.json"
157+
},
158+
"referencedMap": {
159+
"../src/index.ts": [
160+
"../../pkg1/lib/src/index.d.ts"
161+
]
162+
},
163+
"exportedModulesMap": {
164+
"../src/index.ts": [
165+
"../../pkg1/lib/src/index.d.ts"
166+
]
167+
},
168+
"semanticDiagnosticsPerFile": [
169+
"../../../../lib/lib.d.ts",
170+
"../../pkg1/lib/src/index.d.ts",
171+
"../src/index.ts"
172+
]
173+
},
174+
"version": "FakeTSVersion"
175+
}
176+

0 commit comments

Comments
 (0)