Skip to content

Commit 751cb49

Browse files
Merge pull request cerebral#459 from geirsagberg/improve-react-typings
fix(overmind-react): set default config type for hooks and connects
2 parents 0c5e970 + 9d2deb9 commit 751cb49

File tree

1 file changed

+11
-10
lines changed
  • packages/node_modules/overmind-react/src

1 file changed

+11
-10
lines changed

packages/node_modules/overmind-react/src/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import 'proxy-state-tree'
2-
import { unstable_scheduleCallback, unstable_getCurrentPriorityLevel, unstable_cancelCallback } from 'scheduler'
31
import {
2+
Config as DefaultConfig,
43
EventType,
54
IConfiguration,
65
MODE_SSR,
76
Overmind,
8-
OvermindMock,
7+
OvermindMock
98
} from 'overmind'
9+
import 'proxy-state-tree'
1010
import { IMutationCallback } from 'proxy-state-tree'
1111
import * as react from 'react'
12+
import { unstable_cancelCallback, unstable_getCurrentPriorityLevel, unstable_scheduleCallback } from 'scheduler'
1213

1314
const IS_PRODUCTION = process.env.NODE_ENV === 'production'
1415
const IS_TEST = process.env.NODE_ENV === 'test'
@@ -46,7 +47,7 @@ function getDisplayName(component): string {
4647
);
4748
}
4849

49-
export interface IConnect<Config extends IConfiguration> {
50+
export interface IConnect<Config extends IConfiguration = DefaultConfig> {
5051
overmind: {
5152
state: Overmind<Config>['state']
5253
actions: Overmind<Config>['actions']
@@ -246,23 +247,23 @@ const useReaction = <Config extends IConfiguration>(): Overmind<Config>['reacti
246247
return overmind.reaction
247248
}
248249

249-
export const createStateHook: <Config extends IConfiguration>() => () => Overmind<Config>['state'] = () => {
250+
export const createStateHook: <Config extends IConfiguration = DefaultConfig>() => () => Overmind<Config>['state'] = () => {
250251
return useState as any
251252
}
252253

253-
export const createActionsHook: <Config extends IConfiguration>() => () => Overmind<Config>['actions'] = ()=> {
254+
export const createActionsHook: <Config extends IConfiguration = DefaultConfig>() => () => Overmind<Config>['actions'] = ()=> {
254255
return useActions as any
255256
}
256257

257-
export const createEffectsHook: <Config extends IConfiguration>() => () => Overmind<Config>['effects'] = () => {
258+
export const createEffectsHook: <Config extends IConfiguration = DefaultConfig>() => () => Overmind<Config>['effects'] = () => {
258259
return useEffects as any
259260
}
260261

261-
export const createReactionHook: <Config extends IConfiguration>() => () => Overmind<Config>['reaction'] = () => {
262+
export const createReactionHook: <Config extends IConfiguration = DefaultConfig>() => () => Overmind<Config>['reaction'] = () => {
262263
return useReaction as any
263264
}
264265

265-
export const createHook: <Config extends IConfiguration>() => () => {
266+
export const createHook: <Config extends IConfiguration = DefaultConfig>() => () => {
266267
state: Overmind<Config>['state']
267268
actions: Overmind<Config>['actions']
268269
effects: Overmind<Config>['effects']
@@ -285,7 +286,7 @@ export const createHook: <Config extends IConfiguration>() => () => {
285286
}
286287
}
287288

288-
export const createConnect: <ThisConfig extends IConfiguration>() => <Props>(component: IReactComponent<
289+
export const createConnect: <ThisConfig extends IConfiguration = DefaultConfig>() => <Props>(component: IReactComponent<
289290
Props & {
290291
overmind: {
291292
state: Overmind<ThisConfig>['state']

0 commit comments

Comments
 (0)