@@ -1401,18 +1401,20 @@ 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.
14031403namespace Parser {
1404+ /* eslint-disable no-var */
1405+
14041406 // Share a single scanner across all calls to parse a source file. This helps speed things
14051407 // up by avoiding the cost of creating/compiling scanners over and over again.
1406- const scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
1408+ var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
14071409
1408- const disallowInAndDecoratorContext = NodeFlags.DisallowInContext | NodeFlags.DecoratorContext;
1410+ var disallowInAndDecoratorContext = NodeFlags.DisallowInContext | NodeFlags.DecoratorContext;
14091411
14101412 // capture constructors in 'initializeState' to avoid null checks
1411- let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
1412- let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
1413- let IdentifierConstructor: new (kind: SyntaxKind.Identifier, pos: number, end: number) => Identifier;
1414- let PrivateIdentifierConstructor: new (kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) => PrivateIdentifier;
1415- let SourceFileConstructor: new (kind: SyntaxKind.SourceFile, pos: number, end: number) => SourceFile;
1413+ var NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
1414+ var TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
1415+ var IdentifierConstructor: new (kind: SyntaxKind.Identifier, pos: number, end: number) => Identifier;
1416+ var PrivateIdentifierConstructor: new (kind: SyntaxKind.PrivateIdentifier, pos: number, end: number) => PrivateIdentifier;
1417+ var SourceFileConstructor: new (kind: SyntaxKind.SourceFile, pos: number, end: number) => SourceFile;
14161418
14171419 function countNode(node: Node) {
14181420 nodeCount++;
@@ -1421,34 +1423,34 @@ namespace Parser {
14211423
14221424 // Rather than using `createBaseNodeFactory` here, we establish a `BaseNodeFactory` that closes over the
14231425 // constructors above, which are reset each time `initializeState` is called.
1424- const baseNodeFactory: BaseNodeFactory = {
1426+ var baseNodeFactory: BaseNodeFactory = {
14251427 createBaseSourceFileNode: kind => countNode(new SourceFileConstructor(kind, /*pos*/ 0, /*end*/ 0)),
14261428 createBaseIdentifierNode: kind => countNode(new IdentifierConstructor(kind, /*pos*/ 0, /*end*/ 0)),
14271429 createBasePrivateIdentifierNode: kind => countNode(new PrivateIdentifierConstructor(kind, /*pos*/ 0, /*end*/ 0)),
14281430 createBaseTokenNode: kind => countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)),
14291431 createBaseNode: kind => countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0))
14301432 };
14311433
1432- const factory = createNodeFactory(NodeFactoryFlags.NoParenthesizerRules | NodeFactoryFlags.NoNodeConverters | NodeFactoryFlags.NoOriginalNode, baseNodeFactory);
1434+ var factory = createNodeFactory(NodeFactoryFlags.NoParenthesizerRules | NodeFactoryFlags.NoNodeConverters | NodeFactoryFlags.NoOriginalNode, baseNodeFactory);
14331435
1434- let fileName: string;
1435- let sourceFlags: NodeFlags;
1436- let sourceText: string;
1437- let languageVersion: ScriptTarget;
1438- let scriptKind: ScriptKind;
1439- let languageVariant: LanguageVariant;
1440- let parseDiagnostics: DiagnosticWithDetachedLocation[];
1441- let jsDocDiagnostics: DiagnosticWithDetachedLocation[];
1442- let syntaxCursor: IncrementalParser.SyntaxCursor | undefined;
1436+ var fileName: string;
1437+ var sourceFlags: NodeFlags;
1438+ var sourceText: string;
1439+ var languageVersion: ScriptTarget;
1440+ var scriptKind: ScriptKind;
1441+ var languageVariant: LanguageVariant;
1442+ var parseDiagnostics: DiagnosticWithDetachedLocation[];
1443+ var jsDocDiagnostics: DiagnosticWithDetachedLocation[];
1444+ var syntaxCursor: IncrementalParser.SyntaxCursor | undefined;
14431445
1444- let currentToken: SyntaxKind;
1445- let nodeCount: number;
1446- let identifiers: Map<string, string>;
1447- let identifierCount: number;
1446+ var currentToken: SyntaxKind;
1447+ var nodeCount: number;
1448+ var identifiers: Map<string, string>;
1449+ var identifierCount: number;
14481450
1449- let parsingContext: ParsingContext;
1451+ var parsingContext: ParsingContext;
14501452
1451- let notParenthesizedArrow: Set<number> | undefined;
1453+ var notParenthesizedArrow: Set<number> | undefined;
14521454
14531455 // Flags that dictate what parsing context we're in. For example:
14541456 // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is
@@ -1496,10 +1498,10 @@ namespace Parser {
14961498 // Note: it should not be necessary to save/restore these flags during speculative/lookahead
14971499 // parsing. These context flags are naturally stored and restored through normal recursive
14981500 // descent parsing and unwinding.
1499- let contextFlags: NodeFlags;
1501+ var contextFlags: NodeFlags;
15001502
15011503 // Indicates whether we are currently parsing top-level statements.
1502- let topLevel = true;
1504+ var topLevel = true;
15031505
15041506 // Whether or not we've had a parse error since creating the last AST node. If we have
15051507 // encountered an error, it will be stored on the next AST node we create. Parse errors
@@ -1528,7 +1530,8 @@ namespace Parser {
15281530 //
15291531 // Note: any errors at the end of the file that do not precede a regular node, should get
15301532 // attached to the EOF token.
1531- let parseErrorBeforeNextFinishedNode = false;
1533+ var parseErrorBeforeNextFinishedNode = false;
1534+ /* eslint-enable no-var */
15321535
15331536 export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor | undefined, setParentNodes = false, scriptKind?: ScriptKind, setExternalModuleIndicatorOverride?: (file: SourceFile) => void): SourceFile {
15341537 scriptKind = ensureScriptKind(fileName, scriptKind);
0 commit comments