Get apparent type of NewExpression using ts-morph

44 Views Asked by At

I am currently trying to get the type of such declarations:

const x = new BehaviourSubject<string>(); // Should be of type BehaviourSubject<string>

Using ts-morph i tried:

const declX = sourceFile.getVariableDeclarationOrThrow("x");
declX.getType().getText();
declX.getApparentType().getText();

but in both cases i just get any as type. I suspect that i need to evaluate the NewExpression in some form using the ts-typechecker but can not find any references on how to do this.

Any input would be appreciated.

0

There are 0 best solutions below