microsoft / microsoft/TypeScript
Add API to query if SourceFile originated from typeRoots lookup
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
This proposes to add an API Program#isSourceFileFromTypeRoots that is similar to Program#isSourceFileFromExternalLibrary but for typeRoots.
Currently the only way to determine if a SourceFile comes from typeRoots is to use ts.getEffectiveTypeRoots and check if a given SourceFile#fileName starts with any of the paths.
That works if there are no symlinks. With symlinks one needs to use realpath on all of the typeRoots before comparing to fileName as that is already a realpath.
And even that doesn't cover cases where a subdirectory (like node_modules/@types/foo) or an individual file (node_modules/@types/foo/index.d.ts) is a symlink.
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 reading Program#isSourceFileFromExternalLibrary, ts.getEffectiveTypeRoots, and SourceFile#fileName handling. Trace how typeRoots and symlinked directories or files are represented, then add the proposed Program#isSourceFileFromTypeRoots API with coverage for those cases. Done means callers no longer need to compare paths themselves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100