@@ -85,8 +85,10 @@ export const createInstance = <T extends {}>(
85
85
}
86
86
87
87
type Props = AsyncProps < T >
88
+ type State = AsyncState < T >
89
+ type Constructor = AsyncConstructor < T >
88
90
89
- class Async extends React . Component < Props , AsyncState < T > > {
91
+ class Async extends React . Component < Props , State > {
90
92
private mounted = false
91
93
private counter = 0
92
94
private args : any [ ] = [ ]
@@ -108,7 +110,7 @@ export const createInstance = <T extends {}>(
108
110
this . setError = this . setError . bind ( this )
109
111
110
112
const promise = props . promise
111
- const promiseFn = props . promiseFn || defaultProps . promiseFn
113
+ const promiseFn = props . promiseFn || defaultProps . promiseFConstructorn
112
114
const initialValue = props . initialValue || defaultProps . initialValue
113
115
114
116
this . state = {
@@ -269,7 +271,7 @@ export const createInstance = <T extends {}>(
269
271
render ( ) {
270
272
const { children } = this . props
271
273
if ( typeof children === "function" ) {
272
- const render = children as ( state : AsyncState < T > ) => React . ReactNode
274
+ const render = children as ( state : State ) => React . ReactNode
273
275
return < Provider value = { this . state } > { render ( this . state ) } </ Provider >
274
276
}
275
277
if ( children !== undefined && children !== null ) {
@@ -281,19 +283,19 @@ export const createInstance = <T extends {}>(
281
283
282
284
if ( propTypes ) ( Async as React . ComponentClass ) . propTypes = propTypes . Async
283
285
284
- const AsyncInitial : AsyncConstructor < T > [ "Initial" ] = props => (
286
+ const AsyncInitial : Constructor [ "Initial" ] = props => (
285
287
< Consumer > { st => < IfInitial { ...props } state = { st } /> } </ Consumer >
286
288
)
287
- const AsyncPending : AsyncConstructor < T > [ "Pending" ] = props => (
289
+ const AsyncPending : Constructor [ "Pending" ] = props => (
288
290
< Consumer > { st => < IfPending { ...props } state = { st } /> } </ Consumer >
289
291
)
290
- const AsyncFulfilled : AsyncConstructor < T > [ "Fulfilled" ] = props => (
292
+ const AsyncFulfilled : Constructor [ "Fulfilled" ] = props => (
291
293
< Consumer > { st => < IfFulfilled { ...props } state = { st } /> } </ Consumer >
292
294
)
293
- const AsyncRejected : AsyncConstructor < T > [ "Rejected" ] = props => (
295
+ const AsyncRejected : Constructor [ "Rejected" ] = props => (
294
296
< Consumer > { st => < IfRejected { ...props } state = { st } /> } </ Consumer >
295
297
)
296
- const AsyncSettled : AsyncConstructor < T > [ "Settled" ] = props => (
298
+ const AsyncSettled : Constructor [ "Settled" ] = props => (
297
299
< Consumer > { st => < IfSettled { ...props } state = { st } /> } </ Consumer >
298
300
)
299
301
0 commit comments