ts-morph
ts-morph copied to clipboard
Goto declaration from argument parameter
I want to check the type of a parameter of a function and navigate to the declaration if it's within the local project. So far I've gotten the type with,
fn.getParameters().forEach(param => {
const type = param.getType()
// goto dec of type
})
How do I process the declaration of the type from here?
I had trouble with this too recently. Documentation on the Node/Type/Symbol concepts would be helpful to me as well, but this seems to be working:
for (const decl of type.getSymbol().getDeclarations()) {
// ...
}
I'm not so sure about checking if it's local to the project. Currently I'm doing that by keeping a list of exported declarations.