@@ -1401,18 +1401,20 @@ export function parseJSDocTypeExpressionForTests(content: string, start?: number
1401
1401
// parser instances can actually be expensive enough to impact us on projects with many source
1402
1402
// files.
1403
1403
namespace Parser {
1404
+ /* eslint-disable no-var */
1405
+
1404
1406
// Share a single scanner across all calls to parse a source file. This helps speed things
1405
1407
// 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);
1407
1409
1408
- const disallowInAndDecoratorContext = NodeFlags.DisallowInContext | NodeFlags.DecoratorContext;
1410
+ var disallowInAndDecoratorContext = NodeFlags.DisallowInContext | NodeFlags.DecoratorContext;
1409
1411
1410
1412
// 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;
1416
1418
1417
1419
function countNode(node: Node) {
1418
1420
nodeCount++;
@@ -1421,34 +1423,34 @@ namespace Parser {
1421
1423
1422
1424
// Rather than using `createBaseNodeFactory` here, we establish a `BaseNodeFactory` that closes over the
1423
1425
// constructors above, which are reset each time `initializeState` is called.
1424
- const baseNodeFactory: BaseNodeFactory = {
1426
+ var baseNodeFactory: BaseNodeFactory = {
1425
1427
createBaseSourceFileNode: kind => countNode(new SourceFileConstructor(kind, /*pos*/ 0, /*end*/ 0)),
1426
1428
createBaseIdentifierNode: kind => countNode(new IdentifierConstructor(kind, /*pos*/ 0, /*end*/ 0)),
1427
1429
createBasePrivateIdentifierNode: kind => countNode(new PrivateIdentifierConstructor(kind, /*pos*/ 0, /*end*/ 0)),
1428
1430
createBaseTokenNode: kind => countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)),
1429
1431
createBaseNode: kind => countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0))
1430
1432
};
1431
1433
1432
- const factory = createNodeFactory(NodeFactoryFlags.NoParenthesizerRules | NodeFactoryFlags.NoNodeConverters | NodeFactoryFlags.NoOriginalNode, baseNodeFactory);
1434
+ var factory = createNodeFactory(NodeFactoryFlags.NoParenthesizerRules | NodeFactoryFlags.NoNodeConverters | NodeFactoryFlags.NoOriginalNode, baseNodeFactory);
1433
1435
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;
1443
1445
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;
1448
1450
1449
- let parsingContext: ParsingContext;
1451
+ var parsingContext: ParsingContext;
1450
1452
1451
- let notParenthesizedArrow: Set<number> | undefined;
1453
+ var notParenthesizedArrow: Set<number> | undefined;
1452
1454
1453
1455
// Flags that dictate what parsing context we're in. For example:
1454
1456
// Whether or not we are in strict parsing mode. All that changes in strict parsing mode is
@@ -1496,10 +1498,10 @@ namespace Parser {
1496
1498
// Note: it should not be necessary to save/restore these flags during speculative/lookahead
1497
1499
// parsing. These context flags are naturally stored and restored through normal recursive
1498
1500
// descent parsing and unwinding.
1499
- let contextFlags: NodeFlags;
1501
+ var contextFlags: NodeFlags;
1500
1502
1501
1503
// Indicates whether we are currently parsing top-level statements.
1502
- let topLevel = true;
1504
+ var topLevel = true;
1503
1505
1504
1506
// Whether or not we've had a parse error since creating the last AST node. If we have
1505
1507
// encountered an error, it will be stored on the next AST node we create. Parse errors
@@ -1528,7 +1530,8 @@ namespace Parser {
1528
1530
//
1529
1531
// Note: any errors at the end of the file that do not precede a regular node, should get
1530
1532
// attached to the EOF token.
1531
- let parseErrorBeforeNextFinishedNode = false;
1533
+ var parseErrorBeforeNextFinishedNode = false;
1534
+ /* eslint-enable no-var */
1532
1535
1533
1536
export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor | undefined, setParentNodes = false, scriptKind?: ScriptKind, setExternalModuleIndicatorOverride?: (file: SourceFile) => void): SourceFile {
1534
1537
scriptKind = ensureScriptKind(fileName, scriptKind);
0 commit comments