Reduce polymorphism resulting from unstable Node shapes (#51682)

* Move .symbol to Declaration

* simplify some factories

* Move localSymbol to Declaration

* Ensure JSDocContainer types are properly initialized

* Move contextualType from Node to NodeLinks

* Move 'locals' and 'nextContainer' out of Node

* Move 'flowNode' out of 'Node'

* Pre-define endFlowNode/returnFlowNode

* Pre-define some SourceFile properties and a more stable cloneNode

* Don't add excess properties to type nodes in typeToTypeNode

* Refactor wrapSymbolTrackerToReportForContext to improve perf
This commit is contained in:
Ron Buckton
2022-12-13 15:11:10 -05:00
committed by GitHub
parent 7267fcaeb9
commit 6d41964fd0
62 changed files with 2730 additions and 1622 deletions
+10 -2
View File
@@ -126,6 +126,7 @@ export function assertInvariants(node: ts.Node | undefined, parent: ts.Node | un
childName === "nextContainer" ||
childName === "modifiers" ||
childName === "externalModuleIndicator" ||
childName === "original" ||
// for now ignore jsdoc comments
childName === "jsDocComment" ||
childName === "checkJsDirective" ||
@@ -200,9 +201,16 @@ export function sourceFileToJSON(file: ts.Node): string {
case "symbolCount":
case "identifierCount":
case "scriptSnapshot":
case "autoGenerateFlags":
// Blocklist of items we never put in the baseline file.
break;
case "hasExtendedUnicodeEscape":
if ((n as any).hasExtendedUnicodeEscape) {
o.hasExtendedUnicodeEscape = true;
}
break;
case "originalKeywordKind":
o[propertyName] = getKindName((n as any)[propertyName]);
break;
@@ -222,8 +230,8 @@ export function sourceFileToJSON(file: ts.Node): string {
break;
case "nextContainer":
if (n.nextContainer) {
o[propertyName] = { kind: n.nextContainer.kind, pos: n.nextContainer.pos, end: n.nextContainer.end };
if ((n as ts.HasLocals).nextContainer) {
o[propertyName] = { kind: (n as ts.HasLocals).nextContainer!.kind, pos: (n as ts.HasLocals).nextContainer!.pos, end: (n as ts.HasLocals).nextContainer!.end };
}
break;