From 1565f96e4444a6fcdc67b1a911575849ae168dd2 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 3 Nov 2023 12:29:32 -0700 Subject: [PATCH] Deprecate ES3 in commandline parser (#56304) Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- src/compiler/commandLineParser.ts | 1 + src/executeCommandLine/executeCommandLine.ts | 4 +++- .../parseCommandLine/Parse empty options of --target.js | 2 +- ...rect option of target to compiler-options with json api.js | 2 +- ...n of target to compiler-options with jsonSourceFile api.js | 2 +- ...re are multiple invalid strings with jsonSourceFile api.js | 2 +- .../runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js | 2 +- ...t_OutputsSkipped-when-host-can't-provide-terminal-width.js | 2 +- ...-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- 9 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f8477c1d7e9..b8a3d77aa57 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -529,6 +529,7 @@ export const targetOptionDeclaration: CommandLineOptionOfCustomType = { affectsModuleResolution: true, affectsEmit: true, affectsBuildInfo: true, + deprecatedKeys: new Set(["es3"]), paramType: Diagnostics.VERSION, showInSimplifiedHelpView: true, category: Diagnostics.Language_and_Environment, diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 19f16d0ef6e..94b99fb6316 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -395,7 +395,9 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign // Group synonyms: es6/es2015 const inverted: { [value: string]: string[]; } = {}; option.type.forEach((value, name) => { - (inverted[value] ||= []).push(name); + if (!option.deprecatedKeys?.has(name)) { + (inverted[value] ||= []).push(name); + } }); return Object.entries(inverted) .map(([, synonyms]) => synonyms.join("/")) diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --target.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --target.js index 35926083139..315e2343c7e 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --target.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --target.js @@ -7,4 +7,4 @@ FileNames:: 0.ts Errors:: error TS6044: Compiler option 'target' expects an argument. -error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. +error TS6046: Argument for '--target' option must be: 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with json api.js index d86d38e9d9f..57c0d1a0336 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with json api.js @@ -23,5 +23,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. +error TS6046: Argument for '--target' option must be: 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with jsonSourceFile api.js index 29bef221d0b..69558be1110 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of target to compiler-options with jsonSourceFile api.js @@ -23,7 +23,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:3:15 - error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. +tsconfig.json:3:15 - error TS6046: Argument for '--target' option must be: 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. 3 "target": "",    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert tsconfig options when there are multiple invalid strings with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert tsconfig options when there are multiple invalid strings with jsonSourceFile api.js index 37c9d09e746..009f13cf4e7 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert tsconfig options when there are multiple invalid strings with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert tsconfig options when there are multiple invalid strings with jsonSourceFile api.js @@ -47,7 +47,7 @@ Errors::   ~~~  19 }   ~ -tsconfig.json:3:15 - error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. +tsconfig.json:3:15 - error TS6046: Argument for '--target' option must be: 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext'. 3 "target": "<%- options.useTsWithBabel ? 'esnext' : 'es5' %>",    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index ea10f3824a4..7d809130885 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -101,7 +101,7 @@ default: false --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +one of: es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext default: es5 --module, -m diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index e111138e659..c4fcbab8f12 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -101,7 +101,7 @@ default: false --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +one of: es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext default: es5 --module, -m diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index e111138e659..c4fcbab8f12 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -101,7 +101,7 @@ default: false --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +one of: es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext default: es5 --module, -m