mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Don't cache child lists for tokens (#58233)
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
import { Node } from "../_namespaces/ts";
|
||||
import {
|
||||
emptyArray,
|
||||
isNodeKind,
|
||||
Node,
|
||||
} from "../_namespaces/ts";
|
||||
|
||||
const nodeChildren = new WeakMap<Node, Node[] | undefined>();
|
||||
const nodeChildren = new WeakMap<Node, readonly Node[] | undefined>();
|
||||
|
||||
/** @internal */
|
||||
export function getNodeChildren(node: Node): Node[] | undefined {
|
||||
export function getNodeChildren(node: Node): readonly Node[] | undefined {
|
||||
if (!isNodeKind(node.kind)) return emptyArray;
|
||||
|
||||
return nodeChildren.get(node);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function setNodeChildren(node: Node, children: Node[]): Node[] {
|
||||
export function setNodeChildren(node: Node, children: readonly Node[]): readonly Node[] {
|
||||
nodeChildren.set(node, children);
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -6209,7 +6209,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
}
|
||||
|
||||
// @api
|
||||
function createSyntaxList(children: Node[]) {
|
||||
function createSyntaxList(children: readonly Node[]) {
|
||||
const node = createBaseNode<SyntaxList>(SyntaxKind.SyntaxList);
|
||||
setNodeChildren(node, children);
|
||||
return node;
|
||||
|
||||
@@ -9006,7 +9006,7 @@ export interface NodeFactory {
|
||||
// Synthetic Nodes
|
||||
//
|
||||
/** @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember): SyntheticExpression;
|
||||
/** @internal */ createSyntaxList(children: Node[]): SyntaxList;
|
||||
/** @internal */ createSyntaxList(children: readonly Node[]): SyntaxList;
|
||||
|
||||
//
|
||||
// Transformation nodes
|
||||
|
||||
Reference in New Issue
Block a user