Skip to content

WritableDraft flattens variadic tuples into plain arrays, losing tuple structure #1230

@aovchinn

Description

@aovchinn

🐛 Bug Report

after 11.0.0 -> 11.1.4 bump, typescript types changed, build is not passing

To Reproduce

import {produce} from "immer"

interface State {
    foo: [boolean, ...number[]];
}

produce<State>(x => foo(x));

const foo = (x: State) => x;

Observed behavior

Argument of type 'WritableNonArrayDraft<State>' is not assignable to parameter of type 'State'.
  Types of property 'foo' are incompatible.
    Type '(number | boolean)[]' is not assignable to type '[boolean, ...number[]]'.

Expected behavior

should work as in 11.0.0, seems like a slightly breaking change

Environment

  • Immer version:
  • I filed this report against the latest version of Immer

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