microsoft / microsoft/TypeScript
Explicit variance annotations for built-in .d.ts files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
While profiling some projects using typeslayer, I've noticed that according to the type checking traces some time is spent calculating the type variance of common types like Promise<T> and others.
I've explicitly annotated some of these generic types, and I've verified that it that sped up typechecking for some of my complex use-cases.
I've verified that these speed-ups also translate to tsgo by checking with hyperfine.
I'd like to ask if a PR to add explicit type variance to some of the most commonly used library types could be a valuable addition? I could set up a PR so some performance tests could be run to see if it works in aggregate, I just wanted to ask if it's something that aligns with the projects' goals and to maybe understand if this was tried already
Based on my limited understanding the pros would be:
- More people learning about variance and explicit variance annotations
- Slightly increased performance in some complex scenarios
The cons would be:
- Different error messages as now we'd see
superandsubprefixes that might confuse users - larger size on the wire/disk
- higher overhead to parse
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
No source files or tests are named. Start by reviewing the built-in .d.ts library types and the type-checking traces described in the issue, then compare tsgo measurements with hyperfine. Done means agreeing on the target commonly used types and demonstrating the aggregate performance and diagnostic impact with performance tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100