Skip to content

Array expression can't be directly spread into rest-only signature with const modifierΒ #53149

Closed
@Andarist

Description

@Andarist

Bug Report

πŸ”Ž Search Terms

array spread rest const

πŸ•— Version & Regression Information

  • This is only relevant for 5.0+ since it involves const modifier

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare function foo<const T extends readonly unknown[]>(...args: T): T;
foo(...[1, 'bar']); // should be OK
foo(true, ...[1, 'bar']); // OK

declare function foo2<T extends readonly unknown[]>(...args: T): T;
foo2(...[1, 'bar']); // OK
foo2(true, ...[1, 'bar']); // OK

declare function foo3<T extends unknown[]>(...args: T): T;
foo3(...[1, 'bar']); // OK
foo3(true, ...[1, 'bar']); // OK

πŸ™ Actual behavior

the first call is not allowed

πŸ™‚ Expected behavior

the first call should be allowed since the rest of the calls are allowed

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions