Skip to content

Commit 718e63b

Browse files
authored
Add links to github above big var blocks (#52925)
1 parent b39f10f commit 718e63b

File tree

7 files changed

+18
-0
lines changed

7 files changed

+18
-0
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
501501
}
502502

503503
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
504+
// Why var? It avoids TDZ checks in the runtime which can be costly.
505+
// See: https://github.com/microsoft/TypeScript/issues/52924
504506
/* eslint-disable no-var */
505507
var file: SourceFile;
506508
var options: CompilerOptions;

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,8 @@ export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums
13781378

13791379
/** @internal */
13801380
export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1381+
// Why var? It avoids TDZ checks in the runtime which can be costly.
1382+
// See: https://github.com/microsoft/TypeScript/issues/52924
13811383
/* eslint-disable no-var */
13821384
var getPackagesMap = memoize(() => {
13831385
// A package name maps to true when we detect it has .d.ts files.

src/compiler/emitter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,8 @@ export function getFirstProjectOutput(configFile: ParsedCommandLine, ignoreCase:
737737
/** @internal */
738738
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
739739
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, { scriptTransformers, declarationTransformers }: EmitTransformers, emitOnly?: boolean | EmitOnly, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): EmitResult {
740+
// Why var? It avoids TDZ checks in the runtime which can be costly.
741+
// See: https://github.com/microsoft/TypeScript/issues/52924
740742
/* eslint-disable no-var */
741743
var compilerOptions = host.getCompilerOptions();
742744
var sourceMapDataList: SourceMapEmitResult[] | undefined = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
@@ -1358,6 +1360,8 @@ export const createPrinterWithRemoveCommentsNeverAsciiEscape = /* @__PURE__ */ m
13581360
export const createPrinterWithRemoveCommentsOmitTrailingSemicolon = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true, omitTrailingSemicolon: true }));
13591361

13601362
export function createPrinter(printerOptions: PrinterOptions = {}, handlers: PrintHandlers = {}): Printer {
1363+
// Why var? It avoids TDZ checks in the runtime which can be costly.
1364+
// See: https://github.com/microsoft/TypeScript/issues/52924
13611365
/* eslint-disable no-var */
13621366
var {
13631367
hasGlobalName,

src/compiler/parser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,8 @@ export function parseJSDocTypeExpressionForTests(content: string, start?: number
14011401
// parser instances can actually be expensive enough to impact us on projects with many source
14021402
// files.
14031403
namespace Parser {
1404+
// Why var? It avoids TDZ checks in the runtime which can be costly.
1405+
// See: https://github.com/microsoft/TypeScript/issues/52924
14041406
/* eslint-disable no-var */
14051407

14061408
// Share a single scanner across all calls to parse a source file. This helps speed things

src/compiler/scanner.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,8 @@ export function createScanner(languageVersion: ScriptTarget,
961961
start?: number,
962962
length?: number): Scanner {
963963

964+
// Why var? It avoids TDZ checks in the runtime which can be costly.
965+
// See: https://github.com/microsoft/TypeScript/issues/52924
964966
/* eslint-disable no-var */
965967
var text = textInitial!;
966968

src/compiler/sourcemap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export interface SourceMapGeneratorOptions {
3535

3636
/** @internal */
3737
export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoot: string, sourcesDirectoryPath: string, generatorOptions: SourceMapGeneratorOptions): SourceMapGenerator {
38+
// Why var? It avoids TDZ checks in the runtime which can be costly.
39+
// See: https://github.com/microsoft/TypeScript/issues/52924
3840
/* eslint-disable no-var */
3941
var { enter, exit } = generatorOptions.extendedDiagnostics
4042
? performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")

src/compiler/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ export function isTransientSymbol(symbol: Symbol): symbol is TransientSymbol {
596596
const stringWriter = createSingleLineStringWriter();
597597

598598
function createSingleLineStringWriter(): EmitTextWriter {
599+
// Why var? It avoids TDZ checks in the runtime which can be costly.
600+
// See: https://github.com/microsoft/TypeScript/issues/52924
599601
/* eslint-disable no-var */
600602
var str = "";
601603
/* eslint-enable no-var */
@@ -5812,6 +5814,8 @@ export function isNightly() {
58125814

58135815
/** @internal */
58145816
export function createTextWriter(newLine: string): EmitTextWriter {
5817+
// Why var? It avoids TDZ checks in the runtime which can be costly.
5818+
// See: https://github.com/microsoft/TypeScript/issues/52924
58155819
/* eslint-disable no-var */
58165820
var output: string;
58175821
var indent: number;

0 commit comments

Comments
 (0)