Microsoft/TypeScript
GitHub ã§èŠãCan't assign to partial of intersection with mapped type over generic
Open
#56,905 opened on 2023幎12æ30æ¥
Domain: Mapped TypesHelp WantedPossible Improvement
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
"mapped type", "mapped generic type", "intersection", "partial"
ð Version & Regression Information
Current version of Typescript, not sure if it's a regression
⯠Playground Link
No response
ð» Code
Simple to reproduce:
type X = 'a' | 'b' | 'c'
const foo = <T extends X>() => {
const result: Partial<{d:number} & {[P in T]: boolean}> = {
// error: Type '{ d: number; }' is not assignable to type 'Partial<{ d: number; } & { [P in T]: boolean; }>'
d: 1
}
}
ð Actual behavior
I get an error
ð Expected behavior
I am able to use this type in general; I expect to be able to use a partial of it as well. The only thing I've found that satisfies the type is an empty object
Additional information about the issue
No response