TypeScript resolve referenced Interface
Answered
Hello, I'm unable to find a way to resolve Interface fields within PSI.
When I have f.e. two Interfaces:
interface A {
field: string;
}
interface B {
a: A;
}
When I get PSI of B, I get JSTypeImpl class, which contains "A" type. Problem I'm strugling with is, how to get PSI element of "A" even when it is imported and/or aliased.
I'm just trying to list all fields "B" has, but now I have only that field "a" is of "A" type.
I suppose, there is an existing function somewhere within JSLanguage, but I can't find it.
JSResolveUtil.getElementJSType() // returns back itself
ES6PsiUtil.resolveSymbolInModule() // There I'm not even sure what has to be context and scope
Does anyone by a chance have a clue, where to look for it?
Please sign in to leave a comment.
Hello, if I understand your question correctly, I'd suggest to use the following methods:
Alternatively, to get interface A you can use TypeScriptPropertySignature.getTypeElement().getReferenceExpression().resolve() or multiResolve(false)
Yes, thats what I needed, thank you.