Skip to content

Unexpected any[] spreading string into unknown[]-constrained argument positionΒ #52781

@RyanCavanaugh

Description

@RyanCavanaugh

Bug Report

πŸ”Ž Search Terms

any spread string

πŸ•— Version & Regression Information

  • This changed between versions 3.9 and 4.0

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare function foo<T extends unknown[]>(...args: T): T;
// p: any[], expected string[]
const p = foo(..."hello");
// @ts-expect-error
p[0].blah

πŸ™ Actual behavior

p is any[]

πŸ™‚ Expected behavior

p is string[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-repros

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions