diff --git a/__tests__/base.js b/__tests__/base.js index 6cfc05c2..cca8220d 100644 --- a/__tests__/base.js +++ b/__tests__/base.js @@ -490,7 +490,7 @@ function runBaseTest(name, autoFreeze, useStrictShallowCopy, useListener) { expect(nextState.get(key)).toEqual(true) }) - it("state stays the same if the the same item is assigned by key", () => { + it("state stays the same if the same item is assigned by key", () => { const nextState = produce(baseState, s => { s.aMap.set("jediTotal", 42) }) diff --git a/__tests__/produce.ts b/__tests__/produce.ts index f9093688..c3913873 100644 --- a/__tests__/produce.ts +++ b/__tests__/produce.ts @@ -736,7 +736,7 @@ it("infers curried", () => { assert(n, _ as State) } { - // explictly use generic + // explicitly use generic const f = produce(draft => { draft.count++ }) diff --git a/website/docs/typescript.mdx b/website/docs/typescript.mdx index e4e0a68b..cdfd7316 100644 --- a/website/docs/typescript.mdx +++ b/website/docs/typescript.mdx @@ -109,7 +109,7 @@ Note that we did wrap the `Todo` type of the `draft` argument with `Draft`, beca For the returned curried function, `toggler`, We will _narrow_ the _input_ type to `Immutable`, so that even though `Todo` is a mutable type, we will still accept an immutable todo as input argument to `toggler`. -In contrast, Immer will _widen_ the _output_ type of the curried function to `Writable`, to make sure it's output state is also assignable to variables that are not explictly typed to be immutable. +In contrast, Immer will _widen_ the _output_ type of the curried function to `Writable`, to make sure it's output state is also assignable to variables that are not explicitly typed to be immutable. This type narrowing / widening behavior might be unwelcome, maybe even for the simple reason that it results in quite noisy types. So we recommend to specify the generic state type for curried producers instead, in cases where it cannot be inferred directly, like `toggler` above. By doing so the automatic output widening / input narrowing will be skipped. However, the `draft` argument itself will still be inferred to be a writable `Draft`: