flow.js.flow
This file
Path
__tests__/flow/flow.js.flow
76 lines · 1.2 KiB
Last changed by
Merge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
History of this fileTake it
fixed build attempt 2Michel Weststratebefore adoption7d2148c
lines 1–16why, one step back1// @flow2import produce, {setAutoFreeze, setUseProxies} from "../../src/immer"34setAutoFreeze(true)5setUseProxies(true)67// we really don't want this code to actually execute..8const result = produce({x: 3}, draft => {9 draft.x = 41011 // $ExpectError12 console.log(draft.y)13})1415console.log(result.x)16Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 17why, one step back17const result2 = produce({x: 3}, draft => {Merge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 18why, one step back18 return {x: 4}Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
lines 19–22why, one step back19})2021console.log(result2.x)22Merge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
lines 23–26why, one step back23const f = produce((draft): {x: number} => {24 return {x: 4}25})26f({x: 3})Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
lines 27–28why, one step back2728const f2 = produce((draft): void => {})fixed build attempt 2Michel Weststratebefore adoption7d2148c
lines 29–44why, one step back29f2({x: 3})3031// $ExpectError32setAutoFreeze(3)3334// $ExpectError35console.log(result.y)3637// $ExpectError38produce()3940// $ExpectError41produce({x: 3})4243// $ExpectError44produce({x: 3}, [])Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 45–47why, one step back4546{47 // curried & initial argMerge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
lines 48–53why, one step back48 const f = produce(49 (state, increment: number): void => {50 state.x += increment51 },52 {x: 3}53 )Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 54–55why, one step back5455 // $ExpectError Too few argumentsMerge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 56why, one step back56 f({x: 5})Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 57–58why, one step back5758 // $ExpectErrorMerge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 59why, one step back59 f({x: 5}, "test")Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
line 60why, one step back60Merge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 61why, one step back61 f({x: 5}, 3)Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 62–67why, one step back6263 f(undefined, 3)64}6566{67 // curried f & no initial argMerge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 68why, one step back68 const f2 = produce((state: {x: number}, increment: number): void => {Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 69–71why, one step back69 state.x += increment70 })71Merge branch 'kachkaev-add-failing-tests-for-recursive-use'Michel Weststratebefore adoption3db727b
line 72why, one step back72 f2({x: 5}, 3)Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 73–76why, one step back7374 // $ExpectError75 f2(undefined, 3)76}