@@ -37,7 +37,11 @@ export type Action<Value = void> = TAction<App, Value>
3737
3838export type Context = TContext < App >
3939
40- export type Derive < Parent extends object , Value > = TDerive < App , Parent , Value >
40+ export type Derive < Parent extends object , Value > = TDerive <
41+ App ,
42+ ResolveState < Parent > ,
43+ Value
44+ >
4145
4246export type Reaction = TReaction < App >
4347
@@ -479,46 +483,46 @@ export class Overmind<Config extends Configuration> implements BaseApp {
479483 OPERATORS
480484 needs to be in this file for typing override to work
481485*/
482- export type Operator < Input , Output > = TOperator < Input , Output , Context >
486+ export type Operator < Input , Output > = TOperator < Context , Input , Output >
483487
484488export function pipe < BaseContext , A , B , C > (
485- aOperator : TOperator < A , B , BaseContext >
486- ) : TOperator < A , C , BaseContext >
489+ aOperator : TOperator < BaseContext , A , B >
490+ ) : TOperator < BaseContext , A , C >
487491
488492export function pipe < BaseContext , A , B , C , D > (
489- aOperator : TOperator < A , B , BaseContext > ,
490- bOperator : TOperator < B , C , BaseContext >
491- ) : TOperator < A , D , BaseContext >
493+ aOperator : TOperator < BaseContext , A , B > ,
494+ bOperator : TOperator < BaseContext , B , C >
495+ ) : TOperator < BaseContext , A , D >
492496
493497export function pipe < BaseContext , A , B , C , D , E > (
494- aOperator : TOperator < A , B , BaseContext > ,
495- bOperator : TOperator < B , C , BaseContext > ,
496- cOperator : TOperator < C , D , BaseContext >
497- ) : TOperator < A , E , BaseContext >
498+ aOperator : TOperator < BaseContext , A , B > ,
499+ bOperator : TOperator < BaseContext , B , C > ,
500+ cOperator : TOperator < BaseContext , C , D >
501+ ) : TOperator < BaseContext , A , E >
498502
499503export function pipe < BaseContext , A , B , C , D , E , F > (
500- aOperator : TOperator < A , B , BaseContext > ,
501- bOperator : TOperator < B , C , BaseContext > ,
502- cOperator : TOperator < C , D , BaseContext > ,
503- dOperator : TOperator < D , E , BaseContext >
504- ) : TOperator < A , F , BaseContext >
504+ aOperator : TOperator < BaseContext , A , B > ,
505+ bOperator : TOperator < BaseContext , B , C > ,
506+ cOperator : TOperator < BaseContext , C , D > ,
507+ dOperator : TOperator < BaseContext , D , E >
508+ ) : TOperator < BaseContext , A , F >
505509
506510export function pipe < BaseContext , A , B , C , D , E , F , G > (
507- aOperator : TOperator < A , B , BaseContext > ,
508- bOperator : TOperator < B , C , BaseContext > ,
509- cOperator : TOperator < C , D , BaseContext > ,
510- dOperator : TOperator < D , E , BaseContext > ,
511- eOperator : TOperator < E , F , BaseContext >
512- ) : TOperator < A , G , BaseContext >
511+ aOperator : TOperator < BaseContext , A , B > ,
512+ bOperator : TOperator < BaseContext , B , C > ,
513+ cOperator : TOperator < BaseContext , C , D > ,
514+ dOperator : TOperator < BaseContext , D , E > ,
515+ eOperator : TOperator < BaseContext , E , F >
516+ ) : TOperator < BaseContext , A , G >
513517
514518export function pipe < BaseContext , A , B , C , D , E , F , G , H > (
515- aOperator : TOperator < A , B , BaseContext > ,
516- bOperator : TOperator < B , C , BaseContext > ,
517- cOperator : TOperator < C , D , BaseContext > ,
518- dOperator : TOperator < D , E , BaseContext > ,
519- eOperator : TOperator < E , F , BaseContext > ,
520- fOperator : TOperator < F , G , BaseContext >
521- ) : TOperator < A , H , BaseContext >
519+ aOperator : TOperator < BaseContext , A , B > ,
520+ bOperator : TOperator < BaseContext , B , C > ,
521+ cOperator : TOperator < BaseContext , C , D > ,
522+ dOperator : TOperator < BaseContext , D , E > ,
523+ eOperator : TOperator < BaseContext , E , F > ,
524+ fOperator : TOperator < BaseContext , F , G >
525+ ) : TOperator < BaseContext , A , H >
522526
523527export function pipe ( ...operators ) {
524528 const instance = ( err , context , next , final = next ) => {
@@ -632,7 +636,7 @@ function createNextPath(next) {
632636
633637export function map < Input , Output , BaseContext = Context > (
634638 operation : ( input : TValueContext < BaseContext , Input > ) => Output
635- ) : TOperator < Input , Output extends Promise < infer U > ? U : Output , BaseContext > {
639+ ) : TOperator < BaseContext , Input , Output extends Promise < infer U > ? U : Output > {
636640 const instance = ( err , context , next ) => {
637641 if ( err ) next ( err )
638642 else {
@@ -650,7 +654,7 @@ export function map<Input, Output, BaseContext = Context>(
650654
651655export function run < Input , BaseContext = Context > (
652656 operation : ( input : TValueContext < BaseContext , Input > ) => any
653- ) : TOperator < Input , Input , BaseContext > {
657+ ) : TOperator < BaseContext , Input , Input > {
654658 const instance = ( err , context , next ) => {
655659 if ( err ) next ( err )
656660 else {
@@ -672,8 +676,8 @@ export function run<Input, BaseContext = Context>(
672676}
673677
674678export function forEach < Input extends any [ ] , BaseContext = Context > (
675- forEachItemOperator : TOperator < Input [ 0 ] , any , BaseContext >
676- ) : TOperator < Input , Input , BaseContext > {
679+ forEachItemOperator : TOperator < BaseContext , Input [ 0 ] , any >
680+ ) : TOperator < BaseContext , Input , Input > {
677681 const instance = ( err , context , next ) => {
678682 if ( err ) next ( err )
679683 else {
@@ -715,8 +719,8 @@ export function forEach<Input extends any[], BaseContext = Context>(
715719}
716720
717721export function parallel < Input , BaseContext = Context > (
718- operators : TOperator < Input , any , BaseContext > [ ]
719- ) : TOperator < Input , Input , BaseContext > {
722+ operators : TOperator < BaseContext , Input , any > [ ]
723+ ) : TOperator < BaseContext , Input , Input > {
720724 const instance = ( err , context , next ) => {
721725 if ( err ) next ( err )
722726 else {
@@ -758,7 +762,7 @@ export function parallel<Input, BaseContext = Context>(
758762
759763export function filter < Input , BaseContext = Context > (
760764 operation : ( input : TValueContext < BaseContext , Input > ) => boolean
761- ) : TOperator < Input , Input , BaseContext > {
765+ ) : TOperator < BaseContext , Input , Input > {
762766 const instance = ( err , context , next , final ) => {
763767 if ( err ) next ( err )
764768 else {
@@ -810,7 +814,7 @@ export function fork<
810814> (
811815 operation : ( input : TValueContext < BaseContext , Input > ) => keyof Paths ,
812816 paths : Paths
813- ) : TOperator < Input , Input , BaseContext > {
817+ ) : TOperator < BaseContext , Input , Input > {
814818 const instance = ( err , context , next ) => {
815819 if ( err ) next ( err )
816820 else {
@@ -839,10 +843,10 @@ export function fork<
839843export function when < Input , OutputA , OutputB , BaseContext = Context > (
840844 operation : ( input : TValueContext < BaseContext , Input > ) => boolean ,
841845 paths : {
842- true : TOperator < Input , OutputA , BaseContext >
843- false : TOperator < Input , OutputB , BaseContext >
846+ true : TOperator < BaseContext , Input , OutputA >
847+ false : TOperator < BaseContext , Input , OutputB >
844848 }
845- ) : TOperator < Input , OutputA | OutputB , BaseContext > {
849+ ) : TOperator < BaseContext , Input , OutputA | OutputB > {
846850 const instance = ( err , context , next ) => {
847851 if ( err ) next ( err )
848852 else {
@@ -875,7 +879,7 @@ export function when<Input, OutputA, OutputB, BaseContext = Context>(
875879
876880export function wait < Input , BaseContext = Context > (
877881 ms : number
878- ) : TOperator < Input , Input , BaseContext > {
882+ ) : TOperator < BaseContext , Input , Input > {
879883 const instance = ( err , context , next ) => {
880884 if ( err ) next ( err )
881885 else {
@@ -891,7 +895,7 @@ export function wait<Input, BaseContext = Context>(
891895
892896export function debounce < Input , BaseContext = Context > (
893897 ms : number
894- ) : TOperator < Input , Input , BaseContext > {
898+ ) : TOperator < BaseContext , Input , Input > {
895899 let timeout
896900 let previousFinal
897901 const instance = ( err , context , next , final ) => {
0 commit comments