Skip to content

Error type on spreading array with additional props  #59849

@ssalbdivad

Description

@ssalbdivad

🔎 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 #59260

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: IntersectionIncorrect behavior under `T & U` constructsHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions