Skip to content

rest parameter does not play well with generic array #16931

Closed
@amir-arad

Description

@amir-arad

TypeScript Version: 2.3.4

Code

//  error, defined as ???
type Method<A extends Array<any>, R = void> = (...args: A) => R;

// this is still passed
const foo: Method<[number, string], string> = (a: string, b: number) => a + b;
//                 ^^^^^^  ^^^^^^              ^          ^

Expected behavior:
pass validation
Actual behavior:
Error:(1, 47) TS2370:A rest parameter must be of an array type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions