Microsoft/TypeScript

Error type on spreading array with additional props

Open

#59.849 geöffnet am 4. Sept. 2024

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: IntersectionHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

🔎 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

Contributor Guide