Skip to content

Commit dfd4eb6

Browse files
committed
2 parents 5d52c39 + 20d4479 commit dfd4eb6

File tree

946 files changed

+15730
-3798
lines changed

Some content is hidden

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

946 files changed

+15730
-3798
lines changed

package-lock.json

Lines changed: 328 additions & 328 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
@@ -501,49 +501,55 @@ export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
501501
}
502502

503503
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
504-
let file: SourceFile;
505-
let options: CompilerOptions;
506-
let languageVersion: ScriptTarget;
507-
let parent: Node;
508-
let container: IsContainer | EntityNameExpression;
509-
let thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
510-
let blockScopeContainer: IsBlockScopedContainer;
511-
let lastContainer: HasLocals;
512-
let delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag)[];
513-
let seenThisKeyword: boolean;
504+
// Why var? It avoids TDZ checks in the runtime which can be costly.
505+
// See: https://github.com/microsoft/TypeScript/issues/52924
506+
/* eslint-disable no-var */
507+
var file: SourceFile;
508+
var options: CompilerOptions;
509+
var languageVersion: ScriptTarget;
510+
var parent: Node;
511+
var container: IsContainer | EntityNameExpression;
512+
var thisParentContainer: IsContainer | EntityNameExpression; // Container one level up
513+
var blockScopeContainer: IsBlockScopedContainer;
514+
var lastContainer: HasLocals;
515+
var delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag)[];
516+
var seenThisKeyword: boolean;
514517

515518
// state used by control flow analysis
516-
let currentFlow: FlowNode;
517-
let currentBreakTarget: FlowLabel | undefined;
518-
let currentContinueTarget: FlowLabel | undefined;
519-
let currentReturnTarget: FlowLabel | undefined;
520-
let currentTrueTarget: FlowLabel | undefined;
521-
let currentFalseTarget: FlowLabel | undefined;
522-
let currentExceptionTarget: FlowLabel | undefined;
523-
let preSwitchCaseFlow: FlowNode | undefined;
524-
let activeLabelList: ActiveLabel | undefined;
525-
let hasExplicitReturn: boolean;
519+
var currentFlow: FlowNode;
520+
var currentBreakTarget: FlowLabel | undefined;
521+
var currentContinueTarget: FlowLabel | undefined;
522+
var currentReturnTarget: FlowLabel | undefined;
523+
var currentTrueTarget: FlowLabel | undefined;
524+
var currentFalseTarget: FlowLabel | undefined;
525+
var currentExceptionTarget: FlowLabel | undefined;
526+
var preSwitchCaseFlow: FlowNode | undefined;
527+
var activeLabelList: ActiveLabel | undefined;
528+
var hasExplicitReturn: boolean;
526529

527530
// state used for emit helpers
528-
let emitFlags: NodeFlags;
531+
var emitFlags: NodeFlags;
529532

530533
// If this file is an external module, then it is automatically in strict-mode according to
531534
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
532535
// not depending on if we see "use strict" in certain places or if we hit a class/namespace
533536
// or if compiler options contain alwaysStrict.
534-
let inStrictMode: boolean;
537+
var inStrictMode: boolean;
535538

536539
// If we are binding an assignment pattern, we will bind certain expressions differently.
537-
let inAssignmentPattern = false;
540+
var inAssignmentPattern = false;
538541

539-
let symbolCount = 0;
542+
var symbolCount = 0;
540543

541-
let Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
542-
let classifiableNames: Set<__String>;
544+
var Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
545+
var classifiableNames: Set<__String>;
543546

544-
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
545-
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
546-
const bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
547+
var unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
548+
var reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
549+
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
550+
/* eslint-enable no-var */
551+
552+
return bindSourceFile;
547553

548554
/**
549555
* Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file)
@@ -600,8 +606,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
600606
emitFlags = NodeFlags.None;
601607
}
602608

603-
return bindSourceFile;
604-
605609
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
606610
if (getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
607611
// bind in strict mode source files with alwaysStrict option

src/compiler/builder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
generateDjb2Hash,
4646
getDirectoryPath,
4747
getEmitDeclarations,
48+
getIsolatedModules,
4849
getNormalizedAbsolutePath,
4950
getOptionsNameMap,
5051
getOwnKeys,
@@ -763,7 +764,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(
763764

764765
// Since isolated modules dont change js files, files affected by change in signature is itself
765766
// But we need to cleanup semantic diagnostics and queue dts emit for affected files
766-
if (state.compilerOptions.isolatedModules) {
767+
if (getIsolatedModules(state.compilerOptions)) {
767768
const seenFileNamesMap = new Map<Path, true>();
768769
seenFileNamesMap.set(affectedFile.resolvedPath, true);
769770
const queue = BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);

src/compiler/builderState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ExportedModulesFromDeclarationEmit,
1010
GetCanonicalFileName,
1111
getDirectoryPath,
12+
getIsolatedModules,
1213
getSourceFileOfNode,
1314
HostForComputeHash,
1415
isDeclarationFileName,
@@ -635,7 +636,7 @@ export namespace BuilderState {
635636
}
636637

637638
const compilerOptions = programOfThisState.getCompilerOptions();
638-
if (compilerOptions && (compilerOptions.isolatedModules || outFile(compilerOptions))) {
639+
if (compilerOptions && (getIsolatedModules(compilerOptions) || outFile(compilerOptions))) {
639640
return [sourceFileWithUpdatedShape];
640641
}
641642

0 commit comments

Comments
 (0)