dsherret / ts-morph

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
https://ts-morph.com
MIT License
5.02k stars 196 forks source link

[Help] How to resolve types that are imports to the declaring type? #1579

Open douglasg14b opened 1 month ago

douglasg14b commented 1 month ago

I'm been struggle with this and can't seem to find issues or docs that mention this. I've searched on google, stackoverflow, the docs, and tried ChatGPT with no solution. I'm probably missing knowledge of the appropriate terminology.

I'm sure it's documented somewhere, but the discoverability is rather difficult.

I have a type that's imported:

import type { AddressBoxType } from '@ivr3/aws-connect-modules';

interface Outputs {
    ADDRESS_BOX_TYPE: AddressBoxType;
}

The output I get is:

type.getText() // import(\"/home/[redacted]/programming/[redacted]/[redacted]/packages/[redacted]/src/utilities/getAddressBoxType\").AddressBoxType

type.getSymbol() // undefined

I cannot figure out how to resolve the import with ts-morph.

How do you do this?



Similar questions: