Find kind of TypeReference using TypeScript API

Viewed 714

I'm trying to find the kind (class, interface, type alias, enumeration ...) of a TypeReference.

I have this:

const anode = node as ts.TypeReferenceNode;
const symbol = this.typechecker.getSymbolAtLocation(anode.typeName) as ts.Symbol;
const type = this.typechecker.getTypeOfSymbolAtLocation(symbol, anode);
const decls = symbol.getDeclarations() as ts.Declaration[]; 

But the call to getSymbolAtLocation returns undefined.

anode is a TypeReferenceNode (kind 159) according to VSC debugger:

enter image description here

And escapedText ETypes references to an enum reference.

1 Answers
Related