Skip to content

Commit e6cfb77

Browse files
committed
fix(@angular/cli): fix test typings
Blocked by angular#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 angular#5423. Related to TypeStrong/ts-node#283 Fix angular#5332 Fix angular#5351 BREAKING CHANGE: The following files need changes: - `src/tsconfig.spec.json`: remove `files` and `include` entries. Add `"dom"` to the `lib` array. - `src/typings.d.ts`: replace ``` declare var module: { id: string } ``` with ``` declare var module: NodeModule; interface NodeModule { id: string; } ```
1 parent dbaa04f commit e6cfb77

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"experimentalDecorators": true,
1010
"lib": [
1111
"es2016"
12+
"dom"
1213
],<% } %>
1314
"outDir": "<%= relativeRootPath %>/out-tsc/spec",
1415
"module": "commonjs",
@@ -18,11 +19,5 @@
1819
"jasmine",
1920
"node"
2021
]
21-
},
22-
"files": [
23-
"test.ts"
24-
],
25-
"include": [
26-
"**/*.spec.ts"
27-
]
22+
}
2823
}
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/models/webpack-test-config.ts

+1
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) =>

packages/@ngtools/webpack/src/extract_i18n_plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export class ExtractI18nPlugin implements Tapable {
4646
if (!options.hasOwnProperty('tsConfigPath')) {
4747
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
4848
}
49-
this._tsConfigPath = options.tsConfigPath;
49+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
50+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
5051

5152
// Check the base path.
5253
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

packages/@ngtools/webpack/src/plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class AotPlugin implements Tapable {
9696
if (!options.hasOwnProperty('tsConfigPath')) {
9797
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
9898
}
99-
this._tsConfigPath = options.tsConfigPath;
99+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
100+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
100101

101102
// Check the base path.
102103
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

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

+1
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)