Skip to content
Myr

Flow WIP

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 3293adc · Browse files · 6 files+76 added−17 removed
This commit

State

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

Diff stats

6 files+76 added−17 removed

  • tests:+32 added−0 removed
  • other:+44 added−17 removed

6 files+76 added−17 removed

added:__tests__/flow/flow.js+32 added
modified:src/immer.js.flow+28 added-15 removed
1declare export function extendShallowObservable(target: any): any1// @flow23/**4 * Immer takes a state, and runs a function against it.5 * That function can freely mutate the state, as it will create copies-on-write.
5 unmodified lines
11 * @param currentState - the state to start with12 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified13 * @returns The next state: a new state, or the current state if nothing was modified14 */15declare export default function<S>(15declare function produce <S>(16 recipe: (draftState: S, ...extraArgs: any[]) => void17): (currentState: S, ...extraArgs: any[]) => S;18declare function produce <S>(19 currentState: S,20 recipe: (draftState: S) => void18): S21) : S;22function produce() {2324}2526declare export default produce2728// declare export function default <S>(29// recipe: (draftState: S, ...extraArgs: any[]) => void30// )=> (currentState: S, ...extraArgs: any[]) => S31// declare export function default <S>(32// currentState: S,33// recipe: (draftState: S) => void34// ) => S35// curried invocations20declare export default function<S, A, B, C>(21 recipe: (draftState: S, a: A, b: B, c: C) => void22): (currentState: S, a: A, b: B, c: C) => S23declare export default function<S, A, B>(24 recipe: (draftState: S, a: A, b: B) => void25): (currentState: S, a: A, b: B) => S26declare export default function<S, A>(27 recipe: (draftState: S, a: A) => void28): (currentState: S) => S29declare export default function<S>(30 recipe: (draftState: S, ...extraArgs: any[]) => void31): (currentState: S, ...extraArgs: any[]) => S36// declare export default <S, A, B, C>(37// recipe: (draftState: S, a: A, b: B, c: C) => void38// )=> (currentState: S, a: A, b: B, c: C) => S39// declare export default <S, A, B>(40// recipe: (draftState: S, a: A, b: B) => void41// )=> (currentState: S, a: A, b: B) => S42// declare export default <S, A>(43// recipe: (draftState: S, a: A) => void44// )=> (currentState: S) => S4546/**47 * Automatically freezes any state trees generated by immer.48 * This protects against accidental modifications of the state tree outside of an immer function.
10 unmodified lines
added:.flowconfig+8 added
1[ignore]2.*/node_modules34[include]5__tests__/flow67[options]8suppress_comment= \\(.\\|\n\\)*\\$ExpectError
modified:.travis.yml+1 added-1 removed
modified:package.json+3 added-1 removed
modified:yarn.lock+4 added
1371 unmodified lines
1372 resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"1373 dependencies:1374 locate-path "^2.0.0"13751376flow-bin@^0.64.0:1377 version "0.64.0"1378 resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.64.0.tgz#ddd3fb3b183ab1ab35a5d5dec9caf5ebbcded167"13791380for-in@^1.0.1:1381 version "1.0.2"1382 resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"1383
2155 unmodified lines