Skip to content
Myr

Added typings and typings tests

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

authored by Michel Weststrate · committed by Michel Weststrate · parent 2ddcda2 · Browse files · 4 files+35 added−3 removed
This commit

State

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

Diff stats

4 files+35 added−3 removed

  • tests:+21 added−2 removed
  • other:+14 added−1 removed

4 files+35 added−3 removed

modified:__tests__/flow/flow.js.flow+9 added-1 removed
1// @flow2import produce, {setAutoFreeze, setUseProxies, produce as produce2} from "../../src/immer"2import produce, {setAutoFreeze, setUseProxies, produce as produce2, applyPatches, Patch} from "../../src/immer"34setAutoFreeze(true)5setUseProxies(true)6
77 unmodified lines
8485 // $ExpectError86 console.log(draft.y)87 })88}8990{91 let p: Patch[] = []92 produce({ }, d=> {}, (patches, inverse) => {93 p = patches94 })95 applyPatches({}, p)96}
modified:__tests__/types.ts+12 added-1 removed
modified:src/immer.d.ts+2 added
106 unmodified lines
107 * Manually override whether proxies should be used.108 * By default done by using feature detection109 */110export function setUseProxies(useProxies: boolean): void111112export function applyPatches<S>(state: S, patches: Patch[]): S
modified:src/immer.js.flow+12 added-1 removed
1// @flow23export interface Patch {4 op: "replace" | "remove" | "add",5 path: (string|number)[],6 value?: any7}89export type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void1011interface IProduce {12 /**13 * Immer takes a state, and runs a function against it.14 * That function can freely mutate the state, as it will create copies-on-write.
8 unmodified lines
23 * @returns The next state: a new state, or the current state if nothing was modified24 */25 <S>(26 currentState: S,19 recipe: (draftState: S) => S | void27 recipe: (draftState: S) => S | void,28 patchListener?: PatchListener29 ): S;30 // curried invocations with inital state31 <S, A, B, C>(32 recipe: (draftState: S, a: A, b: B, c: C) => S | void,
48 unmodified lines
81 * Manually override whether proxies should be used.82 * By default done by using feature detection83 */84declare export function setUseProxies(useProxies: boolean): void8586declare export function applyPatches<S>(state: S, patches: Patch[]): S