microsoft / microsoft/TypeScript
Language service: open Type.id
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
I am using language service to "traverse" the program, and I would like very much to "remember" which types and symbols I already saw, and to cache my computation results for them. Performance boost and avoiding infinite loops.
The compiler very helpfully supplies id for Type, Symbol and Node, and it seems to be "really, really" unique for symbols and nodes, and "relatively unique" (i.e. within a given typechecker) for types.
The problem is, however, that, unlike nodes and symbols, types hide their ids behind the "internal" qualifier and the lack of accessor function, making them not legally visible to me as a consumer of the language service. Of course, this being JavaScript, nothing prevents me from accessing them anyway, and that is what I currently do, but this is not ideal, because I am not protected from the code evolution in the future.
So it seems to me that nothing stands in the way of adding a getTypeId method to the typechecker, unless I'm missing something very important.
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 with src/compiler/checker.ts and src/compiler/types.ts, especially the Type definition and the typechecker's existing identity handling described in the issue. Trace how public language-service and type-checker APIs are declared and tested, then determine what is needed for a supported type identifier accessor and verify that the exposed identifier remains useful within a typechecker.
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
- Clearly specified
- Newbie friendliness
- 35/100