Skip to content

Commit

Permalink
Update typescript.md (#2764)
Browse files Browse the repository at this point in the history
Typo: "That is to say how could **do** we type ..."
  • Loading branch information
DanThemes authored Oct 1, 2024
1 parent 17b208a commit 976ae9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const useBearStore = create(foo(() => ({ bears: 0 }), 'hello'))
console.log(useBearStore.foo.toUpperCase())
```

Zustand middlewares can mutate the store. But how could we possibly encode the mutation on the type-level? That is to say how could do we type `foo` so that this code compiles?
Zustand middlewares can mutate the store. But how could we possibly encode the mutation on the type-level? That is to say how could we type `foo` so that this code compiles?

For a usual statically typed language, this is impossible. But thanks to TypeScript, Zustand has something called a "higher-kinded mutator" that makes this possible. If you are dealing with complex type problems, like typing a middleware or using the `StateCreator` type, you will have to understand this implementation detail. For this, you can [check out #710](https://github.com/pmndrs/zustand/issues/710).

Expand Down

0 comments on commit 976ae9f

Please sign in to comment.