microsoft / microsoft/TypeScript
Compiler API to resolve path from ImportDeclaration
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Hi there, since TS supports paths in tsconfig.json, is there an API in the compiler (Program, CompilerHost or something) to programmatically resolve real path of an import?
I wrote this transformer https://github.com/longlho/ts-transform-css-modules and it's tripping up on paths that are aliased in tsconfig.json, e.g:
import * as css from 'alias/foo.css'
tsconfig.json
{
"compilerOptions": {
"paths": {
"alias/*": "../../../some_location/*"
}
}
}
I can try to manually reconstruct TS resolver but rather not to.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the compiler's Program and CompilerHost APIs alongside the paths configuration behavior described in the issue. Compare the requested ImportDeclaration resolution with the existing TypeScript resolver, using the linked CSS-modules transformer as context. Done means the compiler exposes a supported way to resolve aliased import paths without manually reconstructing resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100