Skip to content

Commit 8a62567

Browse files
TrySoundrenatorib
authored andcommitted
Fix flow types (#54)
1 parent 72ebd4e commit 8a62567

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

src/index.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ type ListRender<T> = ({|
119119
list: $ReadOnlyArray<T>,
120120
first: () => T | void,
121121
last: () => T | void,
122-
set: Updater<T>,
122+
set: Updater<$ReadOnlyArray<T>>,
123123
push: (value: T) => void,
124124
pull: (predicate: (T) => boolean) => void,
125125
sort: (compare: (a: T, b: T) => -1 | 0 | 1) => void,

tests/test_flow.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ const noop = () => null
2222

2323
/* Active */
2424
{
25-
const render = ({ isActive, bindActive }) => {
25+
const render = ({ isActive, bind }) => {
2626
;(isActive: boolean)
27-
;(bindActive.onMouseDown: Function)
28-
;(bindActive.onMouseUp: Function)
27+
;(bind.onMouseDown: Function)
28+
;(bind.onMouseUp: Function)
2929
// $FlowFixMe
3030
;(isActive: number)
3131
// $FlowFixMe
32-
;(bindActive.onMouseDown: number)
32+
;(bind.onMouseDown: number)
3333
// $FlowFixMe
34-
;(bindActive.onMouseUp: number)
34+
;(bind.onMouseUp: number)
3535
return null
3636
}
3737
const onChange = ({ isActive }) => {
@@ -124,22 +124,22 @@ const noop = () => null
124124

125125
/* Focus */
126126
{
127-
const render = ({ isFocus, bindFocus }) => {
128-
;(isFocus: boolean)
129-
;(bindFocus.onFocusIn: Function)
130-
;(bindFocus.onFocusOut: Function)
127+
const render = ({ isFocused, bind }) => {
128+
;(isFocused: boolean)
129+
;(bind.onFocus: Function)
130+
;(bind.onBlur: Function)
131131
// $FlowFixMe
132-
;(isFocus: number)
132+
;(isFocused: number)
133133
// $FlowFixMe
134-
;(bindFocus.onFocusIn: number)
134+
;(bind.onFocus: number)
135135
// $FlowFixMe
136-
;(bindFocus.onFocusOut: number)
136+
;(bind.onBlur: number)
137137
return null
138138
}
139-
const onChange = ({ isFocus }) => {
140-
;(isFocus: boolean)
139+
const onChange = ({ isFocused }) => {
140+
;(isFocused: boolean)
141141
// $FlowFixMe
142-
;(isFocus: number)
142+
;(isFocused: number)
143143
}
144144
;[
145145
<Focus render={render} />,
@@ -197,22 +197,22 @@ const noop = () => null
197197

198198
/* Hover */
199199
{
200-
const render = ({ isHover, bindHover }) => {
201-
;(isHover: boolean)
202-
;(bindHover.onMouseEnter: Function)
203-
;(bindHover.onMouseLeave: Function)
200+
const render = ({ isHovered, bind }) => {
201+
;(isHovered: boolean)
202+
;(bind.onMouseEnter: Function)
203+
;(bind.onMouseLeave: Function)
204204
// $FlowFixMe
205-
;(isHover: number)
205+
;(isHovered: number)
206206
// $FlowFixMe
207-
;(bindHover.onMouseEnter: number)
207+
;(bind.onMouseEnter: number)
208208
// $FlowFixMe
209-
;(bindHover.onMouseLeave: number)
209+
;(bind.onMouseLeave: number)
210210
return null
211211
}
212-
const onChange = ({ isHover }) => {
213-
;(isHover: boolean)
212+
const onChange = ({ isHovered }) => {
213+
;(isHovered: boolean)
214214
// $FlowFixMe
215-
;(isHover: number)
215+
;(isHovered: number)
216216
}
217217
;[
218218
<Hover render={render} />,
@@ -226,19 +226,19 @@ const noop = () => null
226226

227227
/* List */
228228
{
229-
const render = ({ list, first, last, setList, push, pull, sort }) => {
229+
const render = ({ list, first, last, set, push, pull, sort }) => {
230230
;(list: $ReadOnlyArray<number>)
231231
;(first(): string | number | void)
232232
;(last(): string | number | void)
233-
setList([])
234-
setList([0])
233+
set([])
234+
set([0])
235235
push(0)
236236
pull((d: number) => true)
237237
sort((a: number, b: number) => -1)
238238
// $FlowFixMe
239239
;(list: $ReadOnlyArray<string>)
240240
//$FlowFixMe
241-
setList([''])
241+
set([''])
242242
//$FlowFixMe
243243
push('')
244244
//$FlowFixMe
@@ -468,15 +468,15 @@ const noop = () => null
468468

469469
/* Value with inferred generic */
470470
{
471-
const render = ({ value, setValue }) => {
471+
const render = ({ value, set }) => {
472472
;(value: number | string | boolean)
473473
// $FlowFixMe
474474
;(value: number)
475475
// $FlowFixMe
476476
;(value: string)
477477
// $FlowFixMe
478478
;(value: boolean)
479-
setValue(true)
479+
set(true)
480480
}
481481
const onChange = ({ value }) => {
482482
;(value: number | string)
@@ -501,9 +501,9 @@ const noop = () => null
501501

502502
/* Value with specified generic */
503503
{
504-
const render1 = ({ value, setValue }) => {
504+
const render1 = ({ value, set }) => {
505505
;(value: number | string)
506-
setValue('')
506+
set('')
507507
// $FlowFixMe
508508
;(value: number)
509509
}

0 commit comments

Comments
 (0)