feat(compiler-cli): Check unvalidated combination of ngc and TypeScript (#22293)

closes #20669

PR Close #22293
This commit is contained in:
WilliamKoza 2017-12-02 12:52:11 +01:00 committed by Victor Berchet
parent 28b23f954c
commit 3ceee99e22
3 changed files with 8 additions and 3 deletions

View File

@ -60,6 +60,7 @@ export interface CompilerOptions extends ts.CompilerOptions {
i18nInFile?: string;
i18nInMissingTranslations?: 'error'|'warning'|'ignore';
preserveWhitespaces?: boolean;
disableTypeScriptVersionCheck?: boolean;
}
export interface CompilerHost extends ts.CompilerHost {

View File

@ -132,6 +132,9 @@ export interface CompilerOptions extends ts.CompilerOptions {
// position.
disableExpressionLowering?: boolean;
// Disable TypeScript Version Check.
disableTypeScriptVersionCheck?: boolean;
// Locale of the application
i18nOutLocale?: string;
// Export format (xlf, xlf2 or xmb)

View File

@ -71,10 +71,11 @@ class AngularCompilerProgram implements Program {
rootNames: ReadonlyArray<string>, private options: CompilerOptions,
private host: CompilerHost, oldProgram?: Program) {
this.rootNames = [...rootNames];
const [major, minor] = ts.version.split('.');
Number(major) > 2 || (Number(major) === 2 && Number(minor) >= 4) ||
userError('The Angular Compiler requires TypeScript >= 2.4.');
if (ts.version < '2.4.2' || (ts.version >= '2.7.0' && !options.disableTypeScriptVersionCheck)) {
throw new Error(
`The Angular Compiler requires TypeScript >=2.4.2 and <2.7 but ${ts.version} was found instead.`);
}
this.oldTsProgram = oldProgram ? oldProgram.getTsProgram() : undefined;
if (oldProgram) {