From 7636f7d6cef59b2a1186551302d62b876f589425 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Thu, 15 Feb 2018 02:35:45 +0300 Subject: [PATCH] Fix flow types --- src/index.js.flow | 2 +- tests/test_flow.js | 66 +++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/index.js.flow b/src/index.js.flow index a6047c5b..93735203 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -119,7 +119,7 @@ type ListRender = ({| list: $ReadOnlyArray, first: () => T | void, last: () => T | void, - set: Updater, + set: Updater<$ReadOnlyArray>, push: (value: T) => void, pull: (predicate: (T) => boolean) => void, sort: (compare: (a: T, b: T) => -1 | 0 | 1) => void, diff --git a/tests/test_flow.js b/tests/test_flow.js index be3b8a29..16c589df 100644 --- a/tests/test_flow.js +++ b/tests/test_flow.js @@ -22,16 +22,16 @@ const noop = () => null /* Active */ { - const render = ({ isActive, bindActive }) => { + const render = ({ isActive, bind }) => { ;(isActive: boolean) - ;(bindActive.onMouseDown: Function) - ;(bindActive.onMouseUp: Function) + ;(bind.onMouseDown: Function) + ;(bind.onMouseUp: Function) // $FlowFixMe ;(isActive: number) // $FlowFixMe - ;(bindActive.onMouseDown: number) + ;(bind.onMouseDown: number) // $FlowFixMe - ;(bindActive.onMouseUp: number) + ;(bind.onMouseUp: number) return null } const onChange = ({ isActive }) => { @@ -124,22 +124,22 @@ const noop = () => null /* Focus */ { - const render = ({ isFocus, bindFocus }) => { - ;(isFocus: boolean) - ;(bindFocus.onFocusIn: Function) - ;(bindFocus.onFocusOut: Function) + const render = ({ isFocused, bind }) => { + ;(isFocused: boolean) + ;(bind.onFocus: Function) + ;(bind.onBlur: Function) // $FlowFixMe - ;(isFocus: number) + ;(isFocused: number) // $FlowFixMe - ;(bindFocus.onFocusIn: number) + ;(bind.onFocus: number) // $FlowFixMe - ;(bindFocus.onFocusOut: number) + ;(bind.onBlur: number) return null } - const onChange = ({ isFocus }) => { - ;(isFocus: boolean) + const onChange = ({ isFocused }) => { + ;(isFocused: boolean) // $FlowFixMe - ;(isFocus: number) + ;(isFocused: number) } ;[ , @@ -197,22 +197,22 @@ const noop = () => null /* Hover */ { - const render = ({ isHover, bindHover }) => { - ;(isHover: boolean) - ;(bindHover.onMouseEnter: Function) - ;(bindHover.onMouseLeave: Function) + const render = ({ isHovered, bind }) => { + ;(isHovered: boolean) + ;(bind.onMouseEnter: Function) + ;(bind.onMouseLeave: Function) // $FlowFixMe - ;(isHover: number) + ;(isHovered: number) // $FlowFixMe - ;(bindHover.onMouseEnter: number) + ;(bind.onMouseEnter: number) // $FlowFixMe - ;(bindHover.onMouseLeave: number) + ;(bind.onMouseLeave: number) return null } - const onChange = ({ isHover }) => { - ;(isHover: boolean) + const onChange = ({ isHovered }) => { + ;(isHovered: boolean) // $FlowFixMe - ;(isHover: number) + ;(isHovered: number) } ;[ , @@ -226,19 +226,19 @@ const noop = () => null /* List */ { - const render = ({ list, first, last, setList, push, pull, sort }) => { + const render = ({ list, first, last, set, push, pull, sort }) => { ;(list: $ReadOnlyArray) ;(first(): string | number | void) ;(last(): string | number | void) - setList([]) - setList([0]) + set([]) + set([0]) push(0) pull((d: number) => true) sort((a: number, b: number) => -1) // $FlowFixMe ;(list: $ReadOnlyArray) //$FlowFixMe - setList(['']) + set(['']) //$FlowFixMe push('') //$FlowFixMe @@ -468,7 +468,7 @@ const noop = () => null /* Value with inferred generic */ { - const render = ({ value, setValue }) => { + const render = ({ value, set }) => { ;(value: number | string | boolean) // $FlowFixMe ;(value: number) @@ -476,7 +476,7 @@ const noop = () => null ;(value: string) // $FlowFixMe ;(value: boolean) - setValue(true) + set(true) } const onChange = ({ value }) => { ;(value: number | string) @@ -501,9 +501,9 @@ const noop = () => null /* Value with specified generic */ { - const render1 = ({ value, setValue }) => { + const render1 = ({ value, set }) => { ;(value: number | string) - setValue('') + set('') // $FlowFixMe ;(value: number) }