π Search Terms
synthetic, NodeObject, RemoteNode, getChildren()
π Version & Regression Information
- This changed between versions 6 and 7.1
β― Playground Link
No response
π» Code
index.d.ts
export declare class Client {
constructor(options?: Record<string, unknown>);
}
import {API} from 'typescript/unstable/api/sync';
import type {Declaration} from 'typescript/unstable/ast';
const program = new API().createProgram('./index.d.ts', {});
const checker = program.getProject().checker;
const getSymbol = (child: Declaration) => [checker.getSymbolAtLocation(child), child.getChildren().map(getSymbol)];
console.log(getSymbol(program.getSourcefile('./index.d.ts'));
π Actual behavior
Error: getNodeId requires a RemoteNode
when facing the synthetic node for the constructor keyword:
NodeObject {
kind: 136,
flags: 0,
pos: 2216,
end: 2232,
parent: [RemoteNode],
_data: undefined
}
π Expected behavior
getChildren() only returns nodes that can either be used like any other RemoteNode or at least have a flag or isRemoteNode() typeguard to handle accordingly.
Additional information about the issue
Started as discussion in https://discord.com/channels/508357248330760243/640177429775777792/1553810176790765731
π Search Terms
synthetic, NodeObject, RemoteNode, getChildren()
π Version & Regression Information
β― Playground Link
No response
π» Code
index.d.ts
π Actual behavior
Error: getNodeId requires a RemoteNode
when facing the synthetic node for the
constructorkeyword:π Expected behavior
getChildren()only returns nodes that can either be used like any otherRemoteNodeor at least have a flag orisRemoteNode()typeguard to handle accordingly.Additional information about the issue
Started as discussion in https://discord.com/channels/508357248330760243/640177429775777792/1553810176790765731