diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b338d3ba657..3032b1c3efc 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3962,6 +3962,9 @@ namespace ts { } export function getModifierFlags(node: Node): ModifierFlags { + if (node.kind >= SyntaxKind.FirstToken && node.kind <= SyntaxKind.LastToken) { + return ModifierFlags.None; + } if (node.modifierFlagsCache & ModifierFlags.HasComputedFlags) { return node.modifierFlagsCache & ~ModifierFlags.HasComputedFlags; } @@ -7149,6 +7152,28 @@ namespace ts { this.original = undefined; } + function Token(this: Node, kind: SyntaxKind, pos: number, end: number) { + this.pos = pos; + this.end = end; + this.kind = kind; + this.id = 0; + this.flags = NodeFlags.None; + this.transformFlags = TransformFlags.None; + this.parent = undefined!; + } + + function Identifier(this: Node, kind: SyntaxKind, pos: number, end: number) { + this.pos = pos; + this.end = end; + this.kind = kind; + this.id = 0; + this.flags = NodeFlags.None; + this.transformFlags = TransformFlags.None; + this.parent = undefined!; + this.original = undefined; + this.flowNode = undefined; + } + function SourceMapSource(this: SourceMapSource, fileName: string, text: string, skipTrivia?: (pos: number) => number) { this.fileName = fileName; this.text = text; @@ -7158,8 +7183,8 @@ namespace ts { // eslint-disable-next-line prefer-const export let objectAllocator: ObjectAllocator = { getNodeConstructor: () => Node, - getTokenConstructor: () => Node, - getIdentifierConstructor: () => Node, + getTokenConstructor: () => Token, + getIdentifierConstructor: () => Identifier, getSourceFileConstructor: () => Node, getSymbolConstructor: () => Symbol, getTypeConstructor: () => Type,