Skip to content

Commit

Permalink
fix(@angular/cli): use local typescriptMismatch if available
Browse files Browse the repository at this point in the history
Fix #7678
  • Loading branch information
filipesilva committed Sep 26, 2017
1 parent eee68f0 commit 631c9fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/@angular/cli/upgrade/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export class Version {
}

static assertTypescriptVersion(projectRoot: string) {
if (!CliConfig.fromGlobal().get('warnings.typescriptMismatch')) {
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
if (!config.get('warnings.typescriptMismatch')) {
return;
}
let compilerVersion: string, tsVersion: string;
Expand Down Expand Up @@ -182,7 +183,7 @@ export class Version {
npm install typescript@'${currentCombo.typescript}'
To disable this warning run "ng set --global warnings.typescriptMismatch=false".
To disable this warning run "ng set warnings.typescriptMismatch=false".
` + '\n')));
}
}
Expand Down
15 changes: 13 additions & 2 deletions tests/e2e/tests/misc/typescript-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,33 @@ export default function () {
throw new Error('Expected to have missing dependency error in output.');
}
})
// Warning should show.
.then(() => npm('install', `typescript@${unsupportedTsVersion}`, '--no-save'))
.then(() => ng('build'))
.then((output) => {
if (!output.stdout.match('Using this version can result in undefined behaviour')) {
throw new Error('Expected to have typescript version mismatch warning in output.');
}
})
// Warning should be disabled with global flag.
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=false'))
.then(() => ng('build'))
.then((output) => {
if (output.stdout.match('Using this version can result in undefined behaviour')) {
throw new Error('Expected to not have typescript version mismatch warning in output.');
}
})
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=true'))
// Warning should be disabled with local flag.
.then(() => ng('set', 'warnings.typescriptMismatch=false'))
.then(() => ng('build'))
.then((output) => {
if (output.stdout.match('Using this version can result in undefined behaviour')) {
throw new Error('Expected to not have typescript version mismatch warning in output.');
}
})
.then(() => ng('set', 'warnings.typescriptMismatch=true'))
// Cleanup
.then(() => npm('install'))
.then(() => ng('set', '--global', 'warnings.typescriptMismatch=true'));
.then(() => npm('install'));
}

0 comments on commit 631c9fd

Please sign in to comment.