Repository navigation
[experiment] Avoid resolving property types that cannot be unit types when looking for key properties - #65056
Conversation
… for key properties
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), this PR was updated less than two minutes before this command. Please wait until it has been unchanged for two minutes and try again. |
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
There was a problem hiding this comment.
🟡 Changes recommended
The guard prematurely rejects unresolved generic variadic tuples that can normalize to never, potentially preventing key-property map creation and bypassing the discriminant shortcut in removeSubtypes.
1 open issue
What changed in this PR
This experiment aims to reduce unnecessary property-type resolution when the native TypeScript checker searches for unit-typed discriminant properties.
Changes:
- Adds a shared predicate that skips methods and certain instantiated or mapped properties.
- Uses the predicate in key-property discovery and union subtype reduction.
| File | Description |
|---|---|
tsc/internal/checker/relater.go |
Defines the predicate and applies it to key-property candidate selection. |
tsc/internal/checker/checker.go |
Reuses the predicate when selecting discriminants for subtype reduction. |
Review effort: Balanced
| // An object type other than a mapped type never instantiates to a unit type, so neither does a union containing one | ||
| if core.Some(uninstantiated.Distributed(), func(t *Type) bool { | ||
| return t.flags&TypeFlagsObject != 0 && t.objectFlags&ObjectFlagsMapped == 0 |
…le that can normalize to never

No description provided.