mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user