Skip to content

Commit a99a489

Browse files
committed
Improve test coverage
1 parent d7ac3ad commit a99a489

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/testRunner/unittests/tsc/projectReferences.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ describe("unittests:: tsc:: projectReferences::", () => {
101101
declaration: true,
102102
module: "esnext",
103103
moduleResolution: "bundler",
104+
rootDir: "src",
105+
outDir: "dist",
104106
},
107+
include: ["src"],
105108
}),
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;",
109+
"/home/src/workspaces/project/lib/src/utils.ts": "export const test = () => 'test';",
110+
"/home/src/workspaces/project/lib/dist/utils.d.ts": "export declare const test: () => string;",
108111
"/home/src/workspaces/project/app/tsconfig.json": jsonToReadableText({
109112
compilerOptions: {
110113
module: "esnext",
@@ -114,7 +117,11 @@ describe("unittests:: tsc:: projectReferences::", () => {
114117
{ path: "../lib" },
115118
],
116119
}),
117-
"/home/src/workspaces/project/app/index.ts": `import Test from '../lib/utils';\nconsole.log(Test.test());`,
120+
"/home/src/workspaces/project/app/index.ts": `
121+
import TestSrc from '../lib/src/utils'; // Error
122+
import TestDecl from '../lib/dist/utils'; // Error
123+
console.log(TestSrc.test());
124+
console.log(TestDecl.test());`,
118125
}),
119126
commandLineArgs: ["--p", "app", "--pretty", "false"],
120127
});

tests/baselines/reference/tsc/projectReferences/referenced-project-with-esnext-module-disallows-synthetic-default-imports.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ Input::
66
"composite": true,
77
"declaration": true,
88
"module": "esnext",
9-
"moduleResolution": "bundler"
10-
}
9+
"moduleResolution": "bundler",
10+
"rootDir": "src",
11+
"outDir": "dist"
12+
},
13+
"include": [
14+
"src"
15+
]
1116
}
1217

13-
//// [/home/src/workspaces/project/lib/utils.ts]
18+
//// [/home/src/workspaces/project/lib/src/utils.ts]
1419
export const test = () => 'test';
1520

16-
//// [/home/src/workspaces/project/lib/utils.d.ts]
21+
//// [/home/src/workspaces/project/lib/dist/utils.d.ts]
1722
export declare const test: () => string;
1823

1924
//// [/home/src/workspaces/project/app/tsconfig.json]
@@ -30,8 +35,11 @@ export declare const test: () => string;
3035
}
3136

3237
//// [/home/src/workspaces/project/app/index.ts]
33-
import Test from '../lib/utils';
34-
console.log(Test.test());
38+
39+
import TestSrc from '../lib/src/utils'; // Error
40+
import TestDecl from '../lib/dist/utils'; // Error
41+
console.log(TestSrc.test());
42+
console.log(TestDecl.test());
3543

3644
//// [/home/src/tslibs/TS/Lib/lib.d.ts]
3745
interface Boolean {}
@@ -50,12 +58,15 @@ declare const console: { log(msg: any): void; };
5058

5159
/home/src/tslibs/TS/Lib/tsc.js --p app --pretty false
5260
Output::
53-
app/index.ts(1,8): error TS1192: Module '"/home/src/workspaces/project/lib/utils"' has no default export.
61+
app/index.ts(2,28): error TS1192: Module '"/home/src/workspaces/project/lib/dist/utils"' has no default export.
62+
app/index.ts(3,28): error TS1192: Module '"/home/src/workspaces/project/lib/dist/utils"' has no default export.
5463

5564

5665
//// [/home/src/workspaces/project/app/index.js]
57-
import Test from '../lib/utils';
58-
console.log(Test.test());
66+
import TestSrc from '../lib/src/utils'; // Error
67+
import TestDecl from '../lib/dist/utils'; // Error
68+
console.log(TestSrc.test());
69+
console.log(TestDecl.test());
5970

6071

6172

0 commit comments

Comments
 (0)