From 870c4d6bbe7b3ce9a4afa47cac1dd9f0fe70417d Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 26 Sep 2017 12:11:20 +0100 Subject: [PATCH] fix(@angular/cli): use local typescriptMismatch if available Fix #7678 --- packages/@angular/cli/upgrade/version.ts | 5 +++-- tests/e2e/tests/misc/typescript-warning.ts | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/@angular/cli/upgrade/version.ts b/packages/@angular/cli/upgrade/version.ts index 5ff4dfeea7c2..dfca9756350b 100644 --- a/packages/@angular/cli/upgrade/version.ts +++ b/packages/@angular/cli/upgrade/version.ts @@ -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; @@ -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'))); } } diff --git a/tests/e2e/tests/misc/typescript-warning.ts b/tests/e2e/tests/misc/typescript-warning.ts index 6aacc4281b21..039b08c28424 100644 --- a/tests/e2e/tests/misc/typescript-warning.ts +++ b/tests/e2e/tests/misc/typescript-warning.ts @@ -20,6 +20,7 @@ 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) => { @@ -27,6 +28,7 @@ export default function () { 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) => { @@ -34,8 +36,17 @@ export default function () { 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')); }