Microsoft/TypeScript
GitHub ã§èŠãDistributive conditional types can't distribute over `NoInfer` types wrapping a union
Open
#61,076 opened on 2025幎1æ29æ¥
Domain: Conditional TypesHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
noinfer union distributive conditional distribution
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
type FooEvent = { type: "FOO" };
type BarEvent = { type: "BAR" };
type Input = FooEvent | BarEvent;
type Result = Extract<Input, FooEvent>;
// ^? type Result = { type: "FOO"; }
type Result2 = Extract<NoInfer<Input>, FooEvent>;
// ^? type Result2 = never
ð Actual behavior
Result2 gets computed as never
ð Expected behavior
Result2 should get computed as { type: "FOO"; }
Additional information about the issue
This is repro for the core problem behind this incorrect behavior: TS playground