@@ -5,13 +5,18 @@ import { ProxyStateTree } from 'proxy-state-tree'
55import { createOperators } from './Action'
66import { Derived } from './derived'
77import { 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'
915import { Reaction } from './reaction'
1016import {
1117 BaseApp ,
1218 Configuration ,
1319 TAction ,
14- TApp ,
1520 TDerive ,
1621 TOperation ,
1722 TReaction ,
@@ -65,15 +70,18 @@ export const log = (...objects: any[]) =>
6570
6671const 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+
6876export 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