@@ -22,13 +22,6 @@ export type IReactComponent<P = any> =
2222 | react . ComponentClass < P >
2323 | react . ClassicComponentClass < P >
2424
25- // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
26- type Omit < T , K extends keyof T > = Pick <
27- T ,
28- ( { [ P in keyof T ] : P } &
29- { [ P in K ] : never } & { [ x : string ] : never ; [ x : number ] : never } ) [ keyof T ]
30- >
31-
3225function getFiberType ( component ) {
3326 if ( component . type ) {
3427 // React.memo
@@ -78,7 +71,7 @@ const useCurrentComponent = () => {
7871 : { }
7972}
8073
81- const useState = < Context extends IContext < { } > > (
74+ const useState = < Context extends IContext < { state : { } } > > (
8275 cb ?: ( state : Context [ 'state' ] ) => any
8376) : Context [ 'state' ] => {
8477 const overmind = react . useContext ( context ) as Overmind < any >
@@ -182,7 +175,9 @@ const useState = <Context extends IContext<{}>>(
182175 return state
183176}
184177
185- const useActions = < Context extends IContext < { } > > ( ) : Context [ 'actions' ] => {
178+ const useActions = <
179+ Context extends IContext < { actions : { } } >
180+ > ( ) : Context [ 'actions' ] => {
186181 const overmind = react . useContext ( context ) as Overmind < any >
187182
188183 if ( ! ( overmind as any ) . mode ) {
@@ -192,7 +187,9 @@ const useActions = <Context extends IContext<{}>>(): Context['actions'] => {
192187 return overmind . actions
193188}
194189
195- const useEffects = < Context extends IContext < { } > > ( ) : Context [ 'effects' ] => {
190+ const useEffects = <
191+ Context extends IContext < { effects : { } } >
192+ > ( ) : Context [ 'effects' ] => {
196193 const overmind = react . useContext ( context ) as Overmind < any >
197194
198195 if ( ! ( overmind as any ) . mode ) {
@@ -202,7 +199,9 @@ const useEffects = <Context extends IContext<{}>>(): Context['effects'] => {
202199 return overmind . effects
203200}
204201
205- const useReaction = < Context extends IContext < { } > > ( ) : IReaction < Context > => {
202+ const useReaction = < Context extends IContext < { state : { } } > > ( ) : IReaction <
203+ Context
204+ > => {
206205 const overmind = react . useContext ( context ) as Overmind < any >
207206
208207 if ( ! ( overmind as any ) . mode ) {
@@ -217,24 +216,24 @@ export interface StateHook<Context extends IContext<{}>> {
217216 < T > ( cb ?: ( state : Context [ 'state' ] ) => T ) : T
218217}
219218
220- export const createStateHook : < Context extends IContext < { } > > ( ) => StateHook <
221- Context
222- > = ( ) => useState
219+ export const createStateHook : <
220+ Context extends IContext < { state : { } } >
221+ > ( ) => StateHook < Context > = ( ) => useState
223222
224223export const createActionsHook : <
225- Context extends IContext < { } >
224+ Context extends IContext < { actions : { } } >
226225> ( ) => ( ) => Context [ 'actions' ] = ( ) => {
227226 return useActions as any
228227}
229228
230229export const createEffectsHook : <
231- Context extends IContext < { } >
230+ Context extends IContext < { effects : { } } >
232231> ( ) => ( ) => Context [ 'effects' ] = ( ) => {
233232 return useEffects as any
234233}
235234
236235export const createReactionHook : <
237- Context extends IContext < { } >
236+ Context extends IContext < { state : { } } >
238237> ( ) => ( ) => IReaction < Context > = ( ) => {
239238 return useReaction as any
240239}
0 commit comments