Skip to content

Commit

Permalink
Remove \* from flow type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
benadamstyles committed Aug 3, 2018
1 parent 7ff5962 commit 46ad287
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/set-future-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SetFutureState<P, S> = <E, V>(
self: Component<P, S>,
eventual: Future<E, V> | (() => Promise<V>),
reducer: (value?: V, prevState: S, props: P) => $Shape<S> | null,
onError?: (error: E) => *
onError?: (error: E) => mixed
) => void

export default <P, S>(
Expand Down
4 changes: 2 additions & 2 deletions src/set-future-state.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ declare interface Future<E, V> {

chain<M, F: Future<E, M>>(f: (value: V) => F): F;

fork(onReject: (error: E) => *, onResolve: (value: V) => void): Cancel;
fork(onReject: (error: E) => mixed, onResolve: (value: V) => void): Cancel;
done(callback: Nodeback<E, V>): Cancel;
}

type SetFutureState<P, S> = <E, V>(
self: Component<P, S>,
eventual: Future<E, V> | (() => Promise<V>),
reducer: (value?: V, prevState: S, props: P) => $Shape<S> | null,
onError?: (error: E) => *
onError?: (error: E) => mixed
) => void

declare export default function withFutureState<P, S>(
Expand Down
17 changes: 9 additions & 8 deletions src/set-future-state.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import withFutureState from './set-future-state'
const wait = (ms: number): Promise<void> =>
new Promise(resolve => setTimeout(resolve, ms))

type Props = {
// flowlint-next-line unclear-type:off
eventual: Future<any, any> | (() => Promise<any>),
reducer: *,
onError?: *,
}

type State = {
loading: boolean,
v?: mixed,
props?: {},
}

type Props<V> = {
// flowlint-next-line unclear-type:off
eventual: Future<any, ?V> | (() => Promise<?V>),
reducer: (?V, State) => mixed,
onError?: () => mixed,
}

const unmountTracker = jest.fn()

const Test = withFutureState(
setFutureState =>
class TestBase extends PureComponent<Props, State> {
class TestBase<V> extends PureComponent<Props<V>, State> {
state = {loading: false}

componentWillUnmount() {
Expand All @@ -34,6 +34,7 @@ const Test = withFutureState(

trigger() {
setFutureState(
// $FlowFixMe
this,
this.props.eventual,
this.props.reducer,
Expand Down

0 comments on commit 46ad287

Please sign in to comment.