WritableDraft flattens variadic tuples into plain arrays, losing tuple structure
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 881
- PR merge metrics
- No merged PRs in 30d
Description
🐛 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript reproduction using produce and inspect the WritableNonArrayDraft type involved in the error. Compare the type behavior between Immer 11.0.0 and 11.1.4; done means the variadic tuple remains [boolean, ...number[]] and the shown build error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100