Microsoft/TypeScript
GitHub ã§èŠãError type on spreading array with additional props
Open
#59,849 opened on 2024幎9æ4æ¥
BugDomain: IntersectionHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
array intersection spread any
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
type withExtraProps = extractArray<{ name: string } & string[]>;
// ^? any[]
type extractArray<t extends readonly unknown[]> = [...{ [i in keyof t]: t[i] }];
ð Actual behavior
Inferred as any[] due to an internal error type
ð Expected behavior
Inferred as string[]
Additional information about the issue
@Andarist mentioned this could be related to https://github.com/microsoft/TypeScript/issues/59260