Skip to content
Myr

flow.js.flow

This file

Path

__tests__/flow/flow.js.flow

133 lines · 2.0 KiB

Last changed by

fix(test): faulty .flowconfigaleclarsonbefore adoptione8fe4ba

History of this file

Take it

The walk stopped after 200 commits: lines older than 51648ef point at it.

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

line 1why, one step back
1// @flow

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

lines 2–8why, one step back
2import produce, {
3 setAutoFreeze,4 setUseProxies,5 produce as produce2,6 applyPatches,7 Patch,8 original

fix(test): faulty .flowconfigaleclarsonbefore adoptione8fe4ba

line 9why, one step back
9} from "../../dist/immer.js"

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

lines 10–29why, one step back
10
11setAutoFreeze(true)12setUseProxies(true)1314// we really don't want this code to actually execute..15const result = produce({x: 3}, draft => {16 draft.x = 41718 // $ExpectError19 console.log(draft.y)20})2122console.log(result.x)2324const result2 = produce({x: 3}, draft => {25 return {x: 4}26})2728console.log(result2.x)29

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

lines 30–34why, one step back
30const f = produce(
31 (draft): {x: number} => {32 return {x: 4}33 }34)

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

lines 35–76why, one step back
35f({x: 3})
3637const f2 = produce((draft): void => {})38f2({x: 3})3940// $ExpectError41setAutoFreeze(3)4243// $ExpectError44console.log(result.y)4546// $ExpectError47produce()4849// $ExpectError50produce({x: 3})5152// $ExpectError53produce({x: 3}, [])5455{56 // curried & initial arg57 const f = produce(58 (state, increment: number): void => {59 state.x += increment60 },61 {x: 3}62 )6364 // $ExpectError Too few arguments65 f({x: 5})6667 // $ExpectError68 f({x: 5}, "test")6970 f({x: 5}, 3)7172 f(undefined, 3)73}7475{76 // curried f & no initial arg

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

lines 77–81why, one step back
77 const f2 = produce(
78 (state: {x: number}, increment: number): void => {79 state.x += increment80 }81 )

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

lines 82–102why, one step back
82
83 f2({x: 5}, 3)8485 // $ExpectError86 f2(undefined, 3)87}8889{90 // $ExpectError91 produce2({x: 3})9293 const result = produce2({x: 3}, draft => {94 draft.x = 49596 // $ExpectError97 console.log(draft.y)98 })99}100101{102 let p: Patch[] = []

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

lines 103–109why, one step back
103 produce(
104 {},105 d => {},106 (patches, inverse) => {107 p = patches108 }109 )

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

lines 110–125why, one step back
110 applyPatches({}, p)
111}112113{114 produce({x: 3}, draftState => {115 let a = original(draftState)116 if (a) {117 a.x118 // $ExpectError119 a.y120 }121 })122}123124{125 produce([1], draftState => {

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

line 126why, one step back
126 const a = original(draftState)

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

line 127why, one step back
127 if (a) {

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

line 128why, one step back
128 const b: number = a[0]

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

line 129why, one step back
129 // $ExpectError

chore: run prettier on __tests__/flow/flow.js.flowaleclarsonbefore adoption55258a7

line 130why, one step back
130 const c: string = a[0]

Merge pull request #213 from aleclarson/patch2Michel Weststratebefore adoption51648ef

lines 131–133why, one step back
131 }
132 })133}