Skip to content

Commit 2ff47c7

Browse files
committed
Add module: es2020
1 parent 196c0aa commit 2ff47c7

File tree

68 files changed

+123
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+123
-88
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31437,7 +31437,7 @@ namespace ts {
3143731437
*/
3143831438
function checkClassNameCollisionWithObject(name: Identifier): void {
3143931439
if (languageVersion === ScriptTarget.ES5 && name.escapedText === "Object"
31440-
&& moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.ESNext) {
31440+
&& moduleKind < ModuleKind.ES2015) {
3144131441
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
3144231442
}
3144331443
}
@@ -32597,7 +32597,7 @@ namespace ts {
3259732597
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
3259832598
}
3259932599

32600-
if (moduleKind !== ModuleKind.System && moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.ESNext) {
32600+
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
3260132601
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
3260232602
}
3260332603
}
@@ -35805,7 +35805,9 @@ namespace ts {
3580535805
return grammarErrorOnNode(node.exclamationToken, Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
3580635806
}
3580735807

35808-
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
35808+
const moduleKind = getEmitModuleKind(compilerOptions);
35809+
35810+
if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
3580935811
!(node.parent.parent.flags & NodeFlags.Ambient) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
3581035812
checkESModuleMarker(node.name);
3581135813
}
@@ -36151,7 +36153,7 @@ namespace ts {
3615136153

3615236154
function checkGrammarImportCallExpression(node: ImportCall): boolean {
3615336155
if (moduleKind === ModuleKind.ES2015) {
36154-
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd);
36156+
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
3615536157
}
3615636158

3615736159
if (node.typeArguments) {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ namespace ts {
261261
umd: ModuleKind.UMD,
262262
es6: ModuleKind.ES2015,
263263
es2015: ModuleKind.ES2015,
264+
es2020: ModuleKind.ES2020,
264265
esnext: ModuleKind.ESNext
265266
}),
266267
affectsModuleResolution: true,

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@
903903
"category": "Error",
904904
"code": 1322
905905
},
906-
"Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
906+
"Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": {
907907
"category": "Error",
908908
"code": 1323
909909
},

src/compiler/factory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5157,8 +5157,7 @@ namespace ts {
51575157
const moduleKind = getEmitModuleKind(compilerOptions);
51585158
let create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
51595159
&& moduleKind !== ModuleKind.System
5160-
&& moduleKind !== ModuleKind.ES2015
5161-
&& moduleKind !== ModuleKind.ESNext;
5160+
&& moduleKind < ModuleKind.ES2015;
51625161
if (!create) {
51635162
const helpers = getEmitHelpers(node);
51645163
if (helpers) {

src/compiler/transformer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace ts {
33
function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<SourceFile | Bundle> {
44
switch (moduleKind) {
55
case ModuleKind.ESNext:
6+
case ModuleKind.ES2020:
67
case ModuleKind.ES2015:
78
return transformES2015Module;
89
case ModuleKind.System:

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,7 @@ namespace ts {
24692469
return isExportOfNamespace(node)
24702470
|| (isExternalModuleExport(node)
24712471
&& moduleKind !== ModuleKind.ES2015
2472+
&& moduleKind !== ModuleKind.ES2020
24722473
&& moduleKind !== ModuleKind.ESNext
24732474
&& moduleKind !== ModuleKind.System);
24742475
}

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,6 +5054,7 @@ namespace ts {
50545054
// Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES
50555055
// module kind).
50565056
ES2015 = 5,
5057+
ES2020 = 6,
50575058
ESNext = 99
50585059
}
50595060

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7634,6 +7634,7 @@ namespace ts {
76347634
case ModuleKind.CommonJS:
76357635
case ModuleKind.AMD:
76367636
case ModuleKind.ES2015:
7637+
case ModuleKind.ES2020:
76377638
case ModuleKind.ESNext:
76387639
return true;
76397640
default:

src/services/codefixes/importFixes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ namespace ts.codefix {
378378
return ImportKind.Equals;
379379
case ModuleKind.System:
380380
case ModuleKind.ES2015:
381+
case ModuleKind.ES2020:
381382
case ModuleKind.ESNext:
382383
case ModuleKind.None:
383384
// Fall back to the `import * as ns` style import.

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace ts {
136136
start: undefined,
137137
length: undefined,
138138
}, {
139-
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.",
139+
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.",
140140
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
141141
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
142142

0 commit comments

Comments
 (0)