Skip to content

Add links to github above big var blocks #52925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
}

function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */
var file: SourceFile;
var options: CompilerOptions;
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,8 @@ export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums

/** @internal */
export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */
var getPackagesMap = memoize(() => {
// A package name maps to true when we detect it has .d.ts files.
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ export function getFirstProjectOutput(configFile: ParsedCommandLine, ignoreCase:
/** @internal */
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, { scriptTransformers, declarationTransformers }: EmitTransformers, emitOnly?: boolean | EmitOnly, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): EmitResult {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */
var compilerOptions = host.getCompilerOptions();
var sourceMapDataList: SourceMapEmitResult[] | undefined = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
Expand Down Expand Up @@ -1358,6 +1360,8 @@ export const createPrinterWithRemoveCommentsNeverAsciiEscape = /* @__PURE__ */ m
export const createPrinterWithRemoveCommentsOmitTrailingSemicolon = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true, omitTrailingSemicolon: true }));

export function createPrinter(printerOptions: PrinterOptions = {}, handlers: PrintHandlers = {}): Printer {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */
var {
hasGlobalName,
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,8 @@ export function parseJSDocTypeExpressionForTests(content: string, start?: number
// parser instances can actually be expensive enough to impact us on projects with many source
// files.
namespace Parser {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */

// Share a single scanner across all calls to parse a source file. This helps speed things
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ export function createScanner(languageVersion: ScriptTarget,
start?: number,
length?: number): Scanner {

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

Expand Down
2 changes: 2 additions & 0 deletions src/compiler/sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface SourceMapGeneratorOptions {

/** @internal */
export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoot: string, sourcesDirectoryPath: string, generatorOptions: SourceMapGeneratorOptions): SourceMapGenerator {
// Why var? It avoids TDZ checks in the runtime which can be costly.
// See: https://github.com/microsoft/TypeScript/issues/52924
/* eslint-disable no-var */
var { enter, exit } = generatorOptions.extendedDiagnostics
? performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ export function isTransientSymbol(symbol: Symbol): symbol is TransientSymbol {
const stringWriter = createSingleLineStringWriter();

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

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