Skip to content

Commit ad58c18

Browse files
committed
fix(@angular/cli): fix test typings
Blocked by #5500 (fix is included in this PR so that CI will run). Our unit test webpack config was erroneously sending in entry points to karma-webpack, who should receive no entry points. This in turn was hiding errors related to typeRoots lookups. It was also causing unit tests compilation to behave weirdly: unit test errors would not stop compilation, because other entries would still compile. This might also have contributed to the overall slowness of unit tests in #5423. Fix #5332 Fix #5351 BREAKING CHANGE: The top level `files` and `include` options of `src/tsconfig.spec.json` should be removed. The `src/typings.d.ts` file should be modified to contain the following: ``` /* SystemJS module definition */ declare var module: NodeModule; interface NodeModule { id: string; } ``` Projects using TypeScript 2.0 or TypeScript 4.0 while NOT using tsconfig inheritance need to update the following files: - `src/tsconfig.app.json` - `src/tsconfig.spec.json` - `e2e/tsconfig.e2e.json` By adding the following entry to `compilerOptions`: ``` "typeRoots": [ "../node_modules/@types" ], ```
1 parent dbaa04f commit ad58c18

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"lib": [
1212
"es2016",
1313
"dom"
14+
],
15+
"typeRoots": [
16+
"../node_modules/@types"
1417
],<% } %>
1518
"outDir": "<%= relativeRootPath %>/out-tsc/app",
1619
"module": "es2015",

packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"experimentalDecorators": true,
1010
"lib": [
1111
"es2016"
12+
],
13+
"typeRoots": [
14+
"../node_modules/@types"
1215
],<% } %>
1316
"outDir": "<%= relativeRootPath %>/out-tsc/spec",
1417
"module": "commonjs",
@@ -18,11 +21,5 @@
1821
"jasmine",
1922
"node"
2023
]
21-
},
22-
"files": [
23-
"test.ts"
24-
],
25-
"include": [
26-
"**/*.spec.ts"
27-
]
24+
}
2825
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* SystemJS module definition */
2-
declare var module: {
2+
declare var module: NodeModule;
3+
interface NodeModule {
34
id: string;
4-
};
5+
}

packages/@angular/cli/blueprints/ng/files/e2e/tsconfig.e2e.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"experimentalDecorators": true,
1010
"lib": [
1111
"es2016"
12+
],
13+
"typeRoots": [
14+
"../node_modules/@types"
1215
],<% } %>
1316
"outDir": "../out-tsc/e2e",
1417
"module": "commonjs",

packages/@angular/cli/models/webpack-test-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class WebpackTestConfig extends NgCliWebpackConfig {
2828
];
2929

3030
this.config = webpackMerge(webpackConfigs);
31+
delete this.config.entry;
3132

3233
// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
3334
this.config.plugins = this.config.plugins.filter((plugin: any) =>

tests/e2e/tests/lint/lint-with-exclude.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function () {
77

88
return Promise.resolve()
99
.then(() => ng('set', 'lint.0.exclude', '"**/foo.ts"'))
10+
.then(() => ng('set', 'lint.1.exclude', '"**/foo.ts"'))
1011
.then(() => writeFile(fileName, 'const foo = "";\n'))
1112
.then(() => ng('lint'))
1213
.then(({ stdout }) => {

0 commit comments

Comments
 (0)