Microsoft/TypeScript

Error type on spreading array with additional props

Open

#59,849 opened on 2024幎9月4日

GitHub で芋る
 (1 comment) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
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

https://tsplay.dev/wOdoMN

💻 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

コントリビュヌタヌガむド