Update immer.d.ts
Before adoption: this commit came in with the history the project adopted, so no landing records it.
to correctly type check the use-case of producers that return new state
authored by Daniele Morosinotto · committed by GitHub · parent 38ebb75 · Browse files · 1 file·+11 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+11 added−11 removed
- other:+11 added−11 removed
Provenance
- Commit
9694104- Tree
41ea005- Author
Daniele Morosinotto <d.morosinotto@icloud.com>- Committer
GitHub <noreply@github.com>- Parent
38ebb75
1 file changed+11 added−11 removed
modified:src/immer.d.ts+11 added-11 removed
11 unmodified lines1213141516161718192021222223242526272728293031323233343536373738394041424344444546474849505151525354555556575859596061626363646566676869697071727310 unmodified lines11 unmodified lines * @returns The next state: a new state, or the current state if nothing was modified */export default function<S = any>( currentState: S, recipe: (this: S, draftState: S) => void recipe: (this: S, draftState: S) => void | S): S
// curried invocations with default initial state// 0 additional argumentsexport default function<S = any>( recipe: (this: S, draftState: S) => void, recipe: (this: S, draftState: S) => void | S, initialState: S): (currentState: S | undefined) => S// 1 additional argument of type Aexport default function<S = any, A = any>( recipe: (this: S, draftState: S, a: A) => void, recipe: (this: S, draftState: S, a: A) => void | S, initialState: S): (currentState: S | undefined, a: A) => S// 2 additional arguments of types A and Bexport default function<S = any, A = any, B = any>( recipe: (this: S, draftState: S, a: A, b: B) => void, recipe: (this: S, draftState: S, a: A, b: B) => void | S, initialState: S): (currentState: S | undefined, a: A, b: B) => S// 3 additional arguments of types A, B and Cexport default function<S = any, A = any, B = any, C = any>( recipe: (this: S, draftState: S, a: A, b: B, c: C) => void, recipe: (this: S, draftState: S, a: A, b: B, c: C) => void | S, initialState: S): (currentState: S | undefined, a: A, b: B, c: C) => S// any number of additional arguments, but with loss of type safety// this may be alleviated if "variadic kinds" makes it into Typescript:// https://github.com/Microsoft/TypeScript/issues/5453export default function<S = any>( recipe: (this: S, draftState: S, ...extraArgs: any[]) => void, recipe: (this: S, draftState: S, ...extraArgs: any[]) => void | S, initialState: S): (currentState: S | undefined, ...extraArgs: any[]) => S
// curried invocations without default initial state// 0 additional argumentsexport default function<S = any>( recipe: (this: S, draftState: S) => void recipe: (this: S, draftState: S) => void | S): (currentState: S) => S// 1 additional argument of type Aexport default function<S = any, A = any>( recipe: (this: S, draftState: S, a: A) => void recipe: (this: S, draftState: S, a: A) => void | S): (currentState: S, a: A) => S// 2 additional arguments of types A and Bexport default function<S = any, A = any, B = any>( recipe: (this: S, draftState: S, a: A, b: B) => void recipe: (this: S, draftState: S, a: A, b: B) => void | S): (currentState: S, a: A, b: B) => S// 3 additional arguments of types A, B and Cexport default function<S = any, A = any, B = any, C = any>( recipe: (this: S, draftState: S, a: A, b: B, c: C) => void recipe: (this: S, draftState: S, a: A, b: B, c: C) => void | S): (currentState: S, a: A, b: B, c: C) => S// any number of additional arguments, but with loss of type safety// this may be alleviated if "variadic kinds" makes it into Typescript:// https://github.com/Microsoft/TypeScript/issues/5453export default function<S = any>( recipe: (this: S, draftState: S, ...extraArgs: any[]) => void recipe: (this: S, draftState: S, ...extraArgs: any[]) => void | S): (currentState: S, ...extraArgs: any[]) => S/** * Automatically freezes any state trees generated by immer. * This protects against accidental modifications of the state tree outside of an immer function.10 unmodified lines