Add cache to getSimplifiedConditionalType - #64648
Anders Hejlsberg (ahejlsberg) wants to merge 1 commit into
Conversation
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Anders Hejlsberg (@ahejlsberg), the results of running the DT tests are ready. Everything looks the same! |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The cache must distinguish read and write simplification modes to avoid reusing incorrect results.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds caching for simplified conditional types to improve checker performance.
Changes:
- Adds a conditional-type cache kind.
- Splits cached orchestration from simplification logic.
| File | Description |
|---|---|
tsc/internal/checker/checker.go |
Caches conditional-type simplification results. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| } | ||
|
|
||
| func (c *Checker) getSimplifiedConditionalType(t *Type, writing bool) *Type { | ||
| key := CachedTypeKey{kind: CachedTypeKindSimplifiedConditionalType, typeId: t.id} |
|
Anders Hejlsberg (@ahejlsberg) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
|
No measurable effect on perf tests, likely because we don't have react tests which is where it's supposed to help. |

With this PR we consistently cache results in
getSimplifiedType. Previously, we cached results for indexed access types but not conditional types. Found in performance experiments by Bun team.