feat(compiler-cli): Check unvalidated combination of ngc and TypeScript (#22293)
closes #20669 PR Close #22293
This commit is contained in:
parent
28b23f954c
commit
3ceee99e22
|
@ -60,6 +60,7 @@ export interface CompilerOptions extends ts.CompilerOptions {
|
||||||
i18nInFile?: string;
|
i18nInFile?: string;
|
||||||
i18nInMissingTranslations?: 'error'|'warning'|'ignore';
|
i18nInMissingTranslations?: 'error'|'warning'|'ignore';
|
||||||
preserveWhitespaces?: boolean;
|
preserveWhitespaces?: boolean;
|
||||||
|
disableTypeScriptVersionCheck?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompilerHost extends ts.CompilerHost {
|
export interface CompilerHost extends ts.CompilerHost {
|
||||||
|
|
|
@ -132,6 +132,9 @@ export interface CompilerOptions extends ts.CompilerOptions {
|
||||||
// position.
|
// position.
|
||||||
disableExpressionLowering?: boolean;
|
disableExpressionLowering?: boolean;
|
||||||
|
|
||||||
|
// Disable TypeScript Version Check.
|
||||||
|
disableTypeScriptVersionCheck?: boolean;
|
||||||
|
|
||||||
// Locale of the application
|
// Locale of the application
|
||||||
i18nOutLocale?: string;
|
i18nOutLocale?: string;
|
||||||
// Export format (xlf, xlf2 or xmb)
|
// Export format (xlf, xlf2 or xmb)
|
||||||
|
|
|
@ -71,10 +71,11 @@ class AngularCompilerProgram implements Program {
|
||||||
rootNames: ReadonlyArray<string>, private options: CompilerOptions,
|
rootNames: ReadonlyArray<string>, private options: CompilerOptions,
|
||||||
private host: CompilerHost, oldProgram?: Program) {
|
private host: CompilerHost, oldProgram?: Program) {
|
||||||
this.rootNames = [...rootNames];
|
this.rootNames = [...rootNames];
|
||||||
const [major, minor] = ts.version.split('.');
|
|
||||||
|
|
||||||
Number(major) > 2 || (Number(major) === 2 && Number(minor) >= 4) ||
|
if (ts.version < '2.4.2' || (ts.version >= '2.7.0' && !options.disableTypeScriptVersionCheck)) {
|
||||||
userError('The Angular Compiler requires TypeScript >= 2.4.');
|
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;
|
this.oldTsProgram = oldProgram ? oldProgram.getTsProgram() : undefined;
|
||||||
if (oldProgram) {
|
if (oldProgram) {
|
||||||
|
|
Loading…
Reference in New Issue