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.