Tags: Spades-S/immer
Tags
fix(security): Follow up on CVE-2020-28477 where `path: [["__proto__"… …], "x"]` could still pollute the prototype
fix: isPlainObject: add quick comparison between input and `Object` t… …o short-circuit taxing `Function.toString` invocations (immerjs#805)
fix: immerjs#785 fix type inference for produce incorrectly inferring… … promise (immerjs#786)
fix: immerjs#768 `immerable` field being lost during patch value clon… …ing (immerjs#771)
feature: Improved typescript types The TypeScript typings of Immer have been rewritten, and support better inference now and are more accurate. The best practices are documented here: https://immerjs.github.io/immer/typescript. Please visit that page first when running into any compile errors after updating. The following changes have been made: Immer can now infer the type of the `draft` for curried producers, if they are directly passed to another function / context from which the type can be inferred. So lines like these will now be strongly typed: `setTodo(produce(draft => { draft.done = true }))`, where `setTodo` is a React state updater (for example). Fixes immerjs#720. Immer will now better respect the original types passed to a producer, and generally not wrap any returned types with `Immutable` automatically. BREAKING CHANGE: It is no longer allowed to return `nothing` from a recipe if the target state doesn't accept `undefined`. BREAKING CHANGE: It is no longer allowed to return arbitrary things from a recipe. Recipes should either return nothing, or something that is assignable to the original state type. This will catch mistakes with accidental returns earlier.
docs: add `break` to `switch` block (immerjs#769) I get that there's only one `case` here but for people plucking this example and then using it to build out their own reducer, they'll immediately run into issues as soon as they add a second `case` with no `break` in the first.
fix: Add a type-checking fast path for primitive types (immerjs#755) When `Draft<T>` is applied to a large enum type, TypeScript has to do a lot of unnecessary structural comparisons to confirm that no element of the enum matches `Function`, `Date`, `RegExp`, etc. Determining that they do match `string` or `number`, on the other hand, is trivial. This change splits `PrimitiveType` out of `AtomicObject` so that the fast path can be checked first. In microsoft/TypeScript#42824, this cut the check time from ~2.5 seconds to ~0.3 seconds.
PreviousNext