Skip to content

Commit 1f237a6

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/TypeScript into feat/direct_imports
2 parents cb47799 + 4416d54 commit 1f237a6

File tree

547 files changed

+2285
-1603
lines changed

Some content is hidden

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

547 files changed

+2285
-1603
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/binder.ts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -513,49 +513,55 @@ export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
513513
}
514514

515515
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
516-
let file: SourceFile;
517-
let options: CompilerOptions;
518-
let languageVersion: ScriptTarget;
519-
let parent: Node;
520-
let container: IsContainer | EntityNameExpression;
521-
let thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
522-
let blockScopeContainer: IsBlockScopedContainer;
523-
let lastContainer: HasLocals;
524-
let delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag)[];
525-
let seenThisKeyword: boolean;
516+
// Why var? It avoids TDZ checks in the runtime which can be costly.
517+
// See: https://github.com/microsoft/TypeScript/issues/52924
518+
/* eslint-disable no-var */
519+
var file: SourceFile;
520+
var options: CompilerOptions;
521+
var languageVersion: ScriptTarget;
522+
var parent: Node;
523+
var container: IsContainer | EntityNameExpression;
524+
var thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
525+
var blockScopeContainer: IsBlockScopedContainer;
526+
var lastContainer: HasLocals;
527+
var delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag)[];
528+
var seenThisKeyword: boolean;
526529

527530
// state used by control flow analysis
528-
let currentFlow: FlowNode;
529-
let currentBreakTarget: FlowLabel | undefined;
530-
let currentContinueTarget: FlowLabel | undefined;
531-
let currentReturnTarget: FlowLabel | undefined;
532-
let currentTrueTarget: FlowLabel | undefined;
533-
let currentFalseTarget: FlowLabel | undefined;
534-
let currentExceptionTarget: FlowLabel | undefined;
535-
let preSwitchCaseFlow: FlowNode | undefined;
536-
let activeLabelList: ActiveLabel | undefined;
537-
let hasExplicitReturn: boolean;
531+
var currentFlow: FlowNode;
532+
var currentBreakTarget: FlowLabel | undefined;
533+
var currentContinueTarget: FlowLabel | undefined;
534+
var currentReturnTarget: FlowLabel | undefined;
535+
var currentTrueTarget: FlowLabel | undefined;
536+
var currentFalseTarget: FlowLabel | undefined;
537+
var currentExceptionTarget: FlowLabel | undefined;
538+
var preSwitchCaseFlow: FlowNode | undefined;
539+
var activeLabelList: ActiveLabel | undefined;
540+
var hasExplicitReturn: boolean;
538541

539542
// state used for emit helpers
540-
let emitFlags: NodeFlags;
543+
var emitFlags: NodeFlags;
541544

542545
// If this file is an external module, then it is automatically in strict-mode according to
543546
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
544547
// not depending on if we see "use strict" in certain places or if we hit a class/namespace
545548
// or if compiler options contain alwaysStrict.
546-
let inStrictMode: boolean;
549+
var inStrictMode: boolean;
547550

548551
// If we are binding an assignment pattern, we will bind certain expressions differently.
549-
let inAssignmentPattern = false;
552+
var inAssignmentPattern = false;
550553

551-
let symbolCount = 0;
554+
var symbolCount = 0;
552555

553-
let Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
554-
let classifiableNames: Set<__String>;
556+
var Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
557+
var classifiableNames: Set<__String>;
555558

556-
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
557-
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
558-
const bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
559+
var unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
560+
var reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
561+
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
562+
/* eslint-enable no-var */
563+
564+
return bindSourceFile;
559565

560566
/**
561567
* Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file)
@@ -612,8 +618,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
612618
emitFlags = NodeFlags.None;
613619
}
614620

615-
return bindSourceFile;
616-
617621
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
618622
if (getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
619623
// bind in strict mode source files with alwaysStrict option

0 commit comments

Comments
 (0)