Add error on new module/moduleResolution modes when used in non-nightly TS (#46557)

* Add error on new module/moduleResolution modes when used in non-nightly TS

* Update diagnostic
This commit is contained in:
Wesley Wigham 2021-10-29 11:46:19 -07:00 committed by GitHub
parent 9b1ba8f1e3
commit 28e3cd3a80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View file

@ -3778,6 +3778,11 @@
"category": "Error",
"code": 4123
},
"Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": {
"category": "Error",
"code": 4124
},
"The current host does not support the '{0}' option.": {
"category": "Error",
"code": 5001

View file

@ -3160,6 +3160,21 @@ namespace ts {
}
function verifyCompilerOptions() {
const isNightly = stringContains(version, "-dev");
if (!isNightly) {
if (getEmitModuleKind(options) === ModuleKind.Node12) {
createOptionValueDiagnostic("module", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
}
else if (getEmitModuleKind(options) === ModuleKind.NodeNext) {
createOptionValueDiagnostic("module", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
}
else if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12) {
createOptionValueDiagnostic("moduleResolution", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
}
else if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) {
createOptionValueDiagnostic("moduleResolution", Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
}
}
if (options.strictPropertyInitialization && !getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
}
@ -3696,8 +3711,8 @@ namespace ts {
createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3);
}
function createOptionValueDiagnostic(option1: string, message: DiagnosticMessage, arg0?: string) {
createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0);
function createOptionValueDiagnostic(option1: string, message: DiagnosticMessage, arg0?: string, arg1?: string) {
createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
}
function createDiagnosticForReference(sourceFile: JsonSourceFile | undefined, index: number, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number) {