Skip to content

Commit 4e968bb

Browse files
Copilotandrewbranch
andcommitted
Replace fourslash test with proper tsc test that reproduces the bug
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
1 parent 01c3f08 commit 4e968bb

File tree

3 files changed

+91
-21
lines changed

3 files changed

+91
-21
lines changed

src/testRunner/unittests/tsc/projectReferences.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,35 @@ describe("unittests:: tsc:: projectReferences::", () => {
9090
commandLineArgs: ["--p", "app", "--pretty", "false"],
9191
});
9292

93+
verifyTsc({
94+
scenario: "projectReferences",
95+
subScenario: "referenced project with esnext module disallows synthetic default imports",
96+
sys: () =>
97+
TestServerHost.createWatchedSystem({
98+
"/home/src/workspaces/project/lib/tsconfig.json": jsonToReadableText({
99+
compilerOptions: {
100+
composite: true,
101+
declaration: true,
102+
module: "esnext",
103+
moduleResolution: "bundler",
104+
},
105+
}),
106+
"/home/src/workspaces/project/lib/utils.ts": "export const test = () => 'test';",
107+
"/home/src/workspaces/project/lib/utils.d.ts": "export declare const test: () => string;",
108+
"/home/src/workspaces/project/app/tsconfig.json": jsonToReadableText({
109+
compilerOptions: {
110+
module: "esnext",
111+
moduleResolution: "bundler",
112+
},
113+
references: [
114+
{ path: "../lib" },
115+
],
116+
}),
117+
"/home/src/workspaces/project/app/index.ts": `import Test from '../lib/utils';\nconsole.log(Test.test());`,
118+
}),
119+
commandLineArgs: ["--p", "app", "--pretty", "false"],
120+
});
121+
93122
verifyTsc({
94123
scenario: "projectReferences",
95124
subScenario: "referencing ambient const enum from referenced project with preserveConstEnums",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
currentDirectory:: /home/src/workspaces/project useCaseSensitiveFileNames:: false
2+
Input::
3+
//// [/home/src/workspaces/project/lib/tsconfig.json]
4+
{
5+
"compilerOptions": {
6+
"composite": true,
7+
"declaration": true,
8+
"module": "esnext",
9+
"moduleResolution": "bundler"
10+
}
11+
}
12+
13+
//// [/home/src/workspaces/project/lib/utils.ts]
14+
export const test = () => 'test';
15+
16+
//// [/home/src/workspaces/project/lib/utils.d.ts]
17+
export declare const test: () => string;
18+
19+
//// [/home/src/workspaces/project/app/tsconfig.json]
20+
{
21+
"compilerOptions": {
22+
"module": "esnext",
23+
"moduleResolution": "bundler"
24+
},
25+
"references": [
26+
{
27+
"path": "../lib"
28+
}
29+
]
30+
}
31+
32+
//// [/home/src/workspaces/project/app/index.ts]
33+
import Test from '../lib/utils';
34+
console.log(Test.test());
35+
36+
//// [/home/src/tslibs/TS/Lib/lib.d.ts]
37+
interface Boolean {}
38+
interface Function {}
39+
interface CallableFunction {}
40+
interface NewableFunction {}
41+
interface IArguments {}
42+
interface Number { toExponential: any; }
43+
interface Object {}
44+
interface RegExp {}
45+
interface String { charAt: any; }
46+
interface Array<T> { length: number; [n: number]: T; }
47+
interface ReadonlyArray<T> {}
48+
declare const console: { log(msg: any): void; };
49+
50+
51+
/home/src/tslibs/TS/Lib/tsc.js --p app --pretty false
52+
Output::
53+
app/index.ts(1,8): error TS1192: Module '"/home/src/workspaces/project/lib/utils"' has no default export.
54+
55+
56+
//// [/home/src/workspaces/project/app/index.js]
57+
import Test from '../lib/utils';
58+
console.log(Test.test());
59+
60+
61+
62+
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated

tests/cases/fourslash/syntheticDefaultExportWithProjectReferences.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)