Skip to content

Commit e7f3d21

Browse files
filipesilvadond2clouds
authored andcommitted
fix(@angular/cli): use local typescriptMismatch if available
Fix angular#7678
1 parent 76c2c9e commit e7f3d21

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/@angular/cli/upgrade/version.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export class Version {
144144
}
145145

146146
static assertTypescriptVersion(projectRoot: string) {
147-
if (!CliConfig.fromGlobal().get('warnings.typescriptMismatch')) {
147+
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
148+
if (!config.get('warnings.typescriptMismatch')) {
148149
return;
149150
}
150151
let compilerVersion: string, tsVersion: string;
@@ -182,7 +183,7 @@ export class Version {
182183
183184
npm install typescript@'${currentCombo.typescript}'
184185
185-
To disable this warning run "ng set --global warnings.typescriptMismatch=false".
186+
To disable this warning run "ng set warnings.typescriptMismatch=false".
186187
` + '\n')));
187188
}
188189
}

tests/e2e/tests/misc/typescript-warning.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,33 @@ export default function () {
2020
throw new Error('Expected to have missing dependency error in output.');
2121
}
2222
})
23+
// Warning should show.
2324
.then(() => npm('install', `typescript@${unsupportedTsVersion}`, '--no-save'))
2425
.then(() => ng('build'))
2526
.then((output) => {
2627
if (!output.stdout.match('Using this version can result in undefined behaviour')) {
2728
throw new Error('Expected to have typescript version mismatch warning in output.');
2829
}
2930
})
31+
// Warning should be disabled with global flag.
3032
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=false'))
3133
.then(() => ng('build'))
3234
.then((output) => {
3335
if (output.stdout.match('Using this version can result in undefined behaviour')) {
3436
throw new Error('Expected to not have typescript version mismatch warning in output.');
3537
}
3638
})
39+
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=true'))
40+
// Warning should be disabled with local flag.
41+
.then(() => ng('set', 'warnings.typescriptMismatch=false'))
42+
.then(() => ng('build'))
43+
.then((output) => {
44+
if (output.stdout.match('Using this version can result in undefined behaviour')) {
45+
throw new Error('Expected to not have typescript version mismatch warning in output.');
46+
}
47+
})
48+
.then(() => ng('set', 'warnings.typescriptMismatch=true'))
3749
// Cleanup
38-
.then(() => npm('install'))
39-
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=true'));
50+
.then(() => npm('install'));
4051
}
4152

0 commit comments

Comments
 (0)