Skip to content

Error type on spreading array with additional props Β #59849

Open
@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 TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions