Skip to content

Incompatibility between Tuple type and Array type #30132

@ghost

Description

let a: [number, number];
const b = [1,2];
a = b; // Type 'number[]' is missing the following properties from type '[number, number]': 0, 1ts(2739)

Same error with any array lenghs:

let a: [number, number, number];
const b = [1,2,3];
a = b; // Type 'number[]' is missing the following properties from type '[number, number, number]': 0, 1, 2ts(2739)

I can't set array with fixed length. Just why? Why it isn't working? Seems like a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions