Skip to content
Myr

improve Draft<T> in TypeScript

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- make Draft<T> work in TS 2.8.x - make Draft<T> do nothing for tuples, dates, RegExp objects, functions, and boxed primitives Fixes #215

authored by Alec Larson · committed by aleclarson · parent 18a25b8 · Browse files · 2 files+21 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+21 added−5 removed

  • other:+21 added−5 removed

2 files+21 added−5 removed

modified:src/immer.d.ts+19 added-5 removed
modified:readme.md+2 added
497 unmodified lines
498```499500This ensures that the only place you can modify your state is in your produce callbacks. It even works recursively and with `ReadonlyArray`s!501502Using TypeScript v2.8.x and lower is _not_ supported by Immer.503504## Immer on older JavaScript environments?505506By default `produce` tries to use proxies for optimal performance. However, on older JavaScript engines `Proxy` is not available. For example, when running Microsoft Internet Explorer or React Native on Android. In such cases, Immer will fallback to an ES5 compatible implementation which works identical, but is a bit slower.507
199 unmodified lines