11import {
22 ENVIRONMENT ,
33 EventType ,
4+ IConfiguration ,
45 IContext ,
56 IReaction ,
67 MODE_SSR ,
78 Overmind ,
89 OvermindMock ,
910} from 'overmind'
1011import * as react from 'react'
11- import {
12- unstable_cancelCallback ,
13- unstable_getCurrentPriorityLevel ,
14- unstable_scheduleCallback ,
15- } from 'scheduler'
1612
1713const IS_PRODUCTION = ENVIRONMENT === 'production'
1814const IS_TEST = ENVIRONMENT === 'test'
@@ -23,7 +19,7 @@ const isNode =
2319 process . title . includes ( 'node' )
2420
2521export type IReactComponent < P = any > =
26- | react . StatelessComponent < P >
22+ | react . FunctionComponent < P >
2723 | react . ComponentClass < P >
2824 | react . ClassicComponentClass < P >
2925
@@ -83,7 +79,7 @@ const useCurrentComponent = () => {
8379 : { }
8480}
8581
86- const useState = < Context extends IContext < any > > (
82+ const useState = < Context extends IContext < IConfiguration > > (
8783 cb ?: ( state : Context [ 'state' ] ) => any
8884) : Context [ 'state' ] => {
8985 const overmind = react . useContext ( context ) as Overmind < any >
@@ -187,7 +183,9 @@ const useState = <Context extends IContext<any>>(
187183 return state
188184}
189185
190- const useActions = < Context extends IContext < any > > ( ) : Context [ 'actions' ] => {
186+ const useActions = <
187+ Context extends IContext < IConfiguration >
188+ > ( ) : Context [ 'actions' ] => {
191189 const overmind = react . useContext ( context ) as Overmind < any >
192190
193191 if ( ! ( overmind as any ) . mode ) {
@@ -197,7 +195,9 @@ const useActions = <Context extends IContext<any>>(): Context['actions'] => {
197195 return overmind . actions
198196}
199197
200- const useEffects = < Context extends IContext < any > > ( ) : Context [ 'effects' ] => {
198+ const useEffects = <
199+ Context extends IContext < IConfiguration >
200+ > ( ) : Context [ 'effects' ] => {
201201 const overmind = react . useContext ( context ) as Overmind < any >
202202
203203 if ( ! ( overmind as any ) . mode ) {
@@ -207,7 +207,9 @@ const useEffects = <Context extends IContext<any>>(): Context['effects'] => {
207207 return overmind . effects
208208}
209209
210- const useReaction = < Context extends IContext < any > > ( ) : IReaction < Context > => {
210+ const useReaction = < Context extends IContext < IConfiguration > > ( ) : IReaction <
211+ Context
212+ > => {
211213 const overmind = react . useContext ( context ) as Overmind < any >
212214
213215 if ( ! ( overmind as any ) . mode ) {
@@ -217,29 +219,29 @@ const useReaction = <Context extends IContext<any>>(): IReaction<Context> => {
217219 return overmind . reaction as any
218220}
219221
220- export interface StateHook < Context extends IContext < any > > {
222+ export interface StateHook < Context extends IContext < IConfiguration > > {
221223 ( ) : Context [ 'state' ]
222224 < T > ( cb ?: ( state : Context [ 'state' ] ) => T ) : T
223225}
224226
225- export const createStateHook : < Context extends IContext < any > > ( ) => StateHook <
226- Context
227- > = ( ) => useState
227+ export const createStateHook : <
228+ Context extends IContext < IConfiguration >
229+ > ( ) => StateHook < Context > = ( ) => useState
228230
229231export const createActionsHook : <
230- Context extends IContext < any >
232+ Context extends IContext < IConfiguration >
231233> ( ) => ( ) => Context [ 'actions' ] = ( ) => {
232234 return useActions as any
233235}
234236
235237export const createEffectsHook : <
236- Context extends IContext < any >
238+ Context extends IContext < IConfiguration >
237239> ( ) => ( ) => Context [ 'effects' ] = ( ) => {
238240 return useEffects as any
239241}
240242
241243export const createReactionHook : <
242- Context extends IContext < any >
244+ Context extends IContext < IConfiguration >
243245> ( ) => ( ) => IReaction < Context > = ( ) => {
244246 return useReaction as any
245247}
0 commit comments