Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular/cli): use local typescriptMismatch if available #7836

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
}