Skip to content

[TypeScript] Produced draft is read-only if original state is read-only #97

Description

@olavim

The draft returned by the produce function's callback should make a mutable clone from the original state. Currently immutability is retained:

interface IState {
  readonly foo: boolean;
}

const state: IState = {
  foo: false
};

produce(state, draft => {
  draft.foo = true; // Error: Cannot assign to 'foo' because it is a constant or a read-only property.
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions