Microsoft/TypeScript
GitHub ã§èŠãConditional type flow types missing in the template in mapped types with as clause
Open
#61,246 opened on 2025幎2æ22æ¥
Domain: Mapped TypesHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
as clause renaming filtering mapped type conditional type flow
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
type AcceptNonNullable<T extends {}> = T;
type Test<T> = {
[K in keyof T as T[K] extends {} ? K : never]: AcceptNonNullable<T[K]>;
};
ð Actual behavior
AcceptNonNullable<T[K]> errors with:
Type 'T[K]' does not satisfy the constraint '{}'.
Type 'T[keyof T]' is not assignable to type '{}'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'.
Type 'T[string]' is not assignable to type '{}'.(2344)
ð Expected behavior
It doesn't have to error. It's known that T[K] has to extend {} at this position
Additional information about the issue
No response