0

ImmerJS quotes itself as:

  • Strongly typed, no string based paths selectors etc.

https://immerjs.github.io/immer/docs/introduction#benefits

If it's plain JS I wonder how it can be typed?
What does 'strongly typed' mean in the context of JS?

What is their alternative to string based path selectors? eg get(state, 'fruit.apples') That we should only use array based selectors eg createSelector(['fruit', 'bananas'])?

dcsan
  • 11,333
  • 15
  • 77
  • 118

1 Answers1

0

TypeScript has typings for all native JavaScript API, such as offering autocompletion for array.splice, accessing object properties etc.

Because with Immer you use basically only plain JavaScript APIs, they are strongly typed out of the box.

So in your example, with Immer you'd just state.fruit.apples.push({ name: "golden delicious"}) rather than working with selectors, which is strongly typed (assuming that state typed)

mweststrate
  • 4,890
  • 1
  • 16
  • 26