Skip to content

Commit 65de938

Browse files
authored
Remove target=es3 (#57525)
1 parent 23156cb commit 65de938

File tree

397 files changed

+324
-2291
lines changed

Some content is hidden

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

397 files changed

+324
-2291
lines changed

src/compiler/_namespaces/ts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export * from "../transformers/esnext";
5050
export * from "../transformers/jsx";
5151
export * from "../transformers/es2016";
5252
export * from "../transformers/es2015";
53-
export * from "../transformers/es5";
5453
export * from "../transformers/generators";
5554
export * from "../transformers/module/module";
5655
export * from "../transformers/module/system";

src/compiler/binder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,14 +2573,14 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
25732573
// Provide specialized messages to help the user understand why we think they're in
25742574
// strict mode.
25752575
if (getContainingClass(node)) {
2576-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode;
2576+
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Class_definitions_are_automatically_in_strict_mode;
25772577
}
25782578

25792579
if (file.externalModuleIndicator) {
2580-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
2580+
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Modules_are_automatically_in_strict_mode;
25812581
}
25822582

2583-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
2583+
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5;
25842584
}
25852585

25862586
function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) {

src/compiler/checker.ts

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6571,7 +6571,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
65716571
return parentName;
65726572
}
65736573
const memberName = symbolName(type.symbol);
6574-
if (isIdentifierText(memberName, ScriptTarget.ES3)) {
6574+
if (isIdentifierText(memberName, ScriptTarget.ES5)) {
65756575
return appendReferenceToType(
65766576
parentName as TypeReferenceNode | ImportTypeNode,
65776577
factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined),
@@ -29269,10 +29269,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2926929269
if (container) {
2927029270
if (languageVersion < ScriptTarget.ES2015) {
2927129271
if (container.kind === SyntaxKind.ArrowFunction) {
29272-
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
29272+
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES5_Consider_using_a_standard_function_expression);
2927329273
}
2927429274
else if (hasSyntacticModifier(container, ModifierFlags.Async)) {
29275-
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
29275+
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES5_Consider_using_a_standard_function_or_method);
2927629276
}
2927729277
}
2927829278

@@ -34408,8 +34408,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3440834408
case SyntaxKind.MethodDeclaration:
3440934409
case SyntaxKind.GetAccessor:
3441034410
case SyntaxKind.SetAccessor:
34411-
// For ES3 or decorators with only two parameters we supply only two arguments
34412-
return languageVersion === ScriptTarget.ES3 || signature.parameters.length <= 2 ? 2 : 3;
34411+
// For decorators with only two parameters we supply only two arguments
34412+
return signature.parameters.length <= 2 ? 2 : 3;
3441334413
case SyntaxKind.Parameter:
3441434414
return 3;
3441534415
default:
@@ -35166,13 +35166,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3516635166
}
3516735167

3516835168
function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature {
35169-
if (node.arguments && languageVersion < ScriptTarget.ES5) {
35170-
const spreadIndex = getSpreadArgumentIndex(node.arguments);
35171-
if (spreadIndex >= 0) {
35172-
error(node.arguments[spreadIndex], Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
35173-
}
35174-
}
35175-
3517635169
let expressionType = checkNonNullExpression(node.expression);
3517735170
if (expressionType === silentNeverType) {
3517835171
return silentNeverSignature;
@@ -36990,8 +36983,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3699036983
if (!isClassLike(node.parent)) break;
3699136984

3699236985
// A method or accessor declaration decorator will have either two or three arguments (see
36993-
// `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators for
36994-
// ES3, we will only pass two arguments.
36986+
// `PropertyDecorator` and `MethodDecorator` in core.d.ts).
3699536987

3699636988
const targetType = getParentTypeOfClassElement(node);
3699736989
const targetParam = createParameter("target" as __String, targetType);
@@ -37002,7 +36994,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3700236994
const returnType = isPropertyDeclaration(node) ? voidType :
3700336995
createTypedPropertyDescriptorType(getTypeOfNode(node));
3700436996

37005-
const hasPropDesc = languageVersion !== ScriptTarget.ES3 && (!isPropertyDeclaration(parent) || hasAccessorModifier(parent));
36997+
const hasPropDesc = !isPropertyDeclaration(parent) || hasAccessorModifier(parent);
3700636998
if (hasPropDesc) {
3700736999
const descriptorType = createTypedPropertyDescriptorType(getTypeOfNode(node));
3700837000
const descriptorParam = createParameter("descriptor" as __String, descriptorType);
@@ -37074,8 +37066,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3707437066
error(
3707537067
func,
3707637068
isImportCall(func) ?
37077-
Diagnostics.A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option :
37078-
Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option,
37069+
Diagnostics.A_dynamic_import_call_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option :
37070+
Diagnostics.An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option,
3707937071
);
3708037072
}
3708137073

@@ -41465,18 +41457,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4146541457

4146641458
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
4146741459
if (promiseConstructorName === undefined) {
41468-
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
41460+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
4146941461
return;
4147041462
}
4147141463

4147241464
const promiseConstructorSymbol = resolveEntityName(promiseConstructorName, SymbolFlags.Value, /*ignoreErrors*/ true);
4147341465
const promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
4147441466
if (isErrorType(promiseConstructorType)) {
4147541467
if (promiseConstructorName.kind === SyntaxKind.Identifier && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
41476-
error(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
41468+
error(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
4147741469
}
4147841470
else {
41479-
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
41471+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
4148041472
}
4148141473
return;
4148241474
}
@@ -41485,11 +41477,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4148541477
if (globalPromiseConstructorLikeType === emptyObjectType) {
4148641478
// If we couldn't resolve the global PromiseConstructorLike type we cannot verify
4148741479
// compatibility with __awaiter.
41488-
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
41480+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
4148941481
return;
4149041482
}
4149141483

41492-
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
41484+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
4149341485
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? undefined : chainDiagnosticMessages(/*details*/ undefined, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
4149441486
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
4149541487
return;
@@ -43265,7 +43257,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4326543257
}
4326643258

4326743259
let arrayType = inputType;
43268-
let reportedError = false;
4326943260
let hasStringConstituent = false;
4327043261

4327143262
// If strings are permitted, remove any string-like constituents from the array type.
@@ -43287,13 +43278,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4328743278

4328843279
hasStringConstituent = arrayType !== inputType;
4328943280
if (hasStringConstituent) {
43290-
if (languageVersion < ScriptTarget.ES5) {
43291-
if (errorNode) {
43292-
error(errorNode, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
43293-
reportedError = true;
43294-
}
43295-
}
43296-
4329743281
// Now that we've removed all the StringLike types, if no constituents remain, then the entire
4329843282
// arrayOrStringType was a string.
4329943283
if (arrayType.flags & TypeFlags.Never) {
@@ -43303,7 +43287,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4330343287
}
4330443288

4330543289
if (!isArrayLikeType(arrayType)) {
43306-
if (errorNode && !reportedError) {
43290+
if (errorNode) {
4330743291
// Which error we report depends on whether we allow strings or if there was a
4330843292
// string constituent. For example, if the input type is number | string, we
4330943293
// want to say that number is not an array type. But if the input was just
@@ -46198,10 +46182,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4619846182
grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers);
4619946183
}
4620046184

46201-
if (node.moduleSpecifier && node.exportClause && isNamedExports(node.exportClause) && length(node.exportClause.elements) && languageVersion === ScriptTarget.ES3) {
46202-
checkExternalEmitHelpers(node, ExternalEmitHelpers.CreateBinding);
46203-
}
46204-
4620546185
checkGrammarExportDeclaration(node);
4620646186
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
4620746187
if (node.exportClause && !isNamespaceExport(node.exportClause)) {
@@ -49039,8 +49019,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4903949019
return ["__classPrivateFieldSet"];
4904049020
case ExternalEmitHelpers.ClassPrivateFieldIn:
4904149021
return ["__classPrivateFieldIn"];
49042-
case ExternalEmitHelpers.CreateBinding:
49043-
return ["__createBinding"];
4904449022
case ExternalEmitHelpers.SetFunctionName:
4904549023
return ["__setFunctionName"];
4904649024
case ExternalEmitHelpers.PropKey:
@@ -50122,9 +50100,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
5012250100

5012350101
function checkGrammarAccessor(accessor: AccessorDeclaration): boolean {
5012450102
if (!(accessor.flags & NodeFlags.Ambient) && (accessor.parent.kind !== SyntaxKind.TypeLiteral) && (accessor.parent.kind !== SyntaxKind.InterfaceDeclaration)) {
50125-
if (languageVersion < ScriptTarget.ES5) {
50126-
return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
50127-
}
5012850103
if (languageVersion < ScriptTarget.ES2015 && isPrivateIdentifier(accessor.name)) {
5012950104
return grammarErrorOnNode(accessor.name, Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
5013050105
}

src/compiler/diagnosticMessages.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"category": "Error",
164164
"code": 1054
165165
},
166-
"Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.": {
166+
"Type '{0}' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value.": {
167167
"category": "Error",
168168
"code": 1055
169169
},
@@ -799,15 +799,15 @@
799799
"category": "Error",
800800
"code": 1249
801801
},
802-
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'.": {
802+
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'.": {
803803
"category": "Error",
804804
"code": 1250
805805
},
806-
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode.": {
806+
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Class definitions are automatically in strict mode.": {
807807
"category": "Error",
808808
"code": 1251
809809
},
810-
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode.": {
810+
"Function declarations are not allowed inside blocks in strict mode when targeting 'ES5'. Modules are automatically in strict mode.": {
811811
"category": "Error",
812812
"code": 1252
813813
},
@@ -2420,7 +2420,7 @@
24202420
"category": "Error",
24212421
"code": 2495
24222422
},
2423-
"The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.": {
2423+
"The 'arguments' object cannot be referenced in an arrow function in ES5. Consider using a standard function expression.": {
24242424
"category": "Error",
24252425
"code": 2496
24262426
},
@@ -2520,7 +2520,7 @@
25202520
"category": "Error",
25212521
"code": 2520
25222522
},
2523-
"The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.": {
2523+
"The 'arguments' object cannot be referenced in an async function or method in ES5. Consider using a standard function or method.": {
25242524
"category": "Error",
25252525
"code": 2522
25262526
},
@@ -3135,7 +3135,7 @@
31353135
"category": "Error",
31363136
"code": 2704
31373137
},
3138-
"An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.": {
3138+
"An async function or method in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.": {
31393139
"category": "Error",
31403140
"code": 2705
31413141
},
@@ -3163,7 +3163,7 @@
31633163
"category": "Error",
31643164
"code": 2711
31653165
},
3166-
"A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.": {
3166+
"A dynamic import call in ES5 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.": {
31673167
"category": "Error",
31683168
"code": 2712
31693169
},
@@ -4229,10 +4229,6 @@
42294229
"category": "Error",
42304230
"code": 5047
42314231
},
4232-
"Option '{0}' cannot be specified when option 'target' is 'ES3'.": {
4233-
"category": "Error",
4234-
"code": 5048
4235-
},
42364232
"Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
42374233
"category": "Error",
42384234
"code": 5051
@@ -5065,7 +5061,7 @@
50655061
"category": "Message",
50665062
"code": 6171
50675063
},
5068-
"Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'.": {
5064+
"Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5'.": {
50695065
"category": "Message",
50705066
"code": 6179
50715067
},

0 commit comments

Comments
 (0)