Microsoft/TypeScript

Error type on spreading array with additional props

Open

#59,849 建立於 2024年9月4日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: IntersectionHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

🔎 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

貢獻者指南