Skip to content

Commit c7793fb

Browse files
committed
fix(overmind): fix types to avoid the 'import' function in exported types
1 parent 4bc957d commit c7793fb

File tree

1 file changed

+14
-6
lines changed
  • packages/node_modules/overmind/src

1 file changed

+14
-6
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ import { ProxyStateTree } from 'proxy-state-tree'
55
import { createOperators } from './Action'
66
import { Derived } from './derived'
77
import { Devtools, Message, safeValue } from './Devtools'
8-
import { EventType, Events, Options } from './internalTypes'
8+
import {
9+
EventType,
10+
Events,
11+
Options,
12+
ResolveActions,
13+
ResolveState,
14+
} from './internalTypes'
915
import { Reaction } from './reaction'
1016
import {
1117
BaseApp,
1218
Configuration,
1319
TAction,
14-
TApp,
1520
TDerive,
1621
TOperation,
1722
TReaction,
@@ -65,15 +70,18 @@ export const log = (...objects: any[]) =>
6570

6671
const hotReloadingCache = {}
6772

73+
// We do not use TApp<Config> directly to type the class in order to avoid
74+
// the 'import(...)' function to be used in exported types.
75+
6876
export class Overmind<Config extends Configuration> implements BaseApp {
6977
private proxyStateTree: ProxyStateTree
7078
initialized: Promise<any>
7179
eventHub: EventEmitter<Events>
7280
devtools: Devtools
73-
actions: TApp<Config>['actions']
74-
state: TApp<Config>['state']
81+
actions: ResolveActions<Config['actions'] & {}>
82+
state: ResolveState<Config['state'] & {}>
7583
// We add the `effects` here so that App implements BaseApp (makes types simpler).
76-
effects: TApp<Config>['effects'] & { state: TApp<Config>['state'] }
84+
effects: Config['effects'] & { state: ResolveState<Config['state'] & {}> }
7785
constructor(configuration: Config, options: Options = {}) {
7886
const name = options.name || 'MyApp'
7987

@@ -358,7 +366,7 @@ export class Overmind<Config extends Configuration> implements BaseApp {
358366
return {
359367
add(
360368
name: string,
361-
stateCb: (state: TApp<Config>['state']) => any,
369+
stateCb: (state: ResolveState<Config['state'] & {}>) => any,
362370
cb: Function
363371
) {
364372
const reaction = new Reaction(

0 commit comments

Comments
 (0)