Skip to content

Commit 763d882

Browse files
authored
Drop code in tsgo-port that references ES5 or <ES2015 (#62670)
1 parent bf40cd8 commit 763d882

File tree

1,922 files changed

+9481
-14625
lines changed

Some content is hidden

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

1,922 files changed

+9481
-14625
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import {
9191
getContainingClass,
9292
getEffectiveContainerForJSDocTemplateTag,
9393
getElementOrPropertyAccessName,
94-
getEmitScriptTarget,
9594
getEnclosingBlockScopeContainer,
9695
getEnclosingContainer,
9796
getErrorSpanForNode,
@@ -280,7 +279,6 @@ import {
280279
QualifiedName,
281280
removeFileExtension,
282281
ReturnStatement,
283-
ScriptTarget,
284282
SetAccessorDeclaration,
285283
setParent,
286284
setParentRecursive,
@@ -523,7 +521,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
523521
/* eslint-disable no-var */
524522
var file: SourceFile;
525523
var options: CompilerOptions;
526-
var languageVersion: ScriptTarget;
527524
var parent: Node;
528525
var container: IsContainer | EntityNameExpression;
529526
var thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
@@ -583,7 +580,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
583580
function bindSourceFile(f: SourceFile, opts: CompilerOptions) {
584581
file = f;
585582
options = opts;
586-
languageVersion = getEmitScriptTarget(options);
587583
inStrictMode = bindInStrictMode(file, opts);
588584
classifiableNames = new Set();
589585
symbolCount = 0;
@@ -606,7 +602,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
606602

607603
file = undefined!;
608604
options = undefined!;
609-
languageVersion = undefined!;
610605
parent = undefined!;
611606
container = undefined!;
612607
thisParentContainer = undefined!;
@@ -2673,36 +2668,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
26732668
}
26742669
}
26752670

2676-
function getStrictModeBlockScopeFunctionDeclarationMessage(node: Node) {
2677-
// Provide specialized messages to help the user understand why we think they're in
2678-
// strict mode.
2679-
if (getContainingClass(node)) {
2680-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Class_definitions_are_automatically_in_strict_mode;
2681-
}
2682-
2683-
if (file.externalModuleIndicator) {
2684-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5_Modules_are_automatically_in_strict_mode;
2685-
}
2686-
2687-
return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES5;
2688-
}
2689-
2690-
function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) {
2691-
if (languageVersion < ScriptTarget.ES2015) {
2692-
// Report error if function is not top level function declaration
2693-
if (
2694-
blockScopeContainer.kind !== SyntaxKind.SourceFile &&
2695-
blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration &&
2696-
!isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)
2697-
) {
2698-
// We check first if the name is inside class declaration or class expression; if so give explicit message
2699-
// otherwise report generic error message.
2700-
const errorSpan = getErrorSpanForNode(file, node);
2701-
file.bindDiagnostics.push(createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
2702-
}
2703-
}
2704-
}
2705-
27062671
function checkStrictModePostfixUnaryExpression(node: PostfixUnaryExpression) {
27072672
// Grammar checking
27082673
// The identifier eval or arguments may not appear as the LeftHandSideExpression of an
@@ -2731,7 +2696,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
27312696

27322697
function checkStrictModeLabeledStatement(node: LabeledStatement) {
27332698
// Grammar checking for labeledStatement
2734-
if (inStrictMode && getEmitScriptTarget(options) >= ScriptTarget.ES2015) {
2699+
if (inStrictMode) {
27352700
if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) {
27362701
errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here);
27372702
}
@@ -3725,7 +3690,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
37253690

37263691
checkStrictModeFunctionName(node);
37273692
if (inStrictMode) {
3728-
checkStrictModeFunctionDeclaration(node);
37293693
bindBlockScopedDeclaration(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes);
37303694
}
37313695
else {

0 commit comments

Comments
 (0)