@@ -73,11 +73,6 @@ export interface ModelPropertiesDeclaration {
7373 [ key : string ] : ModelPrimitive | IAnyType
7474}
7575
76- /** intersect two object types, but omit keys of B from A before doing so */
77- type OmitMerge < A , B > = {
78- [ K in keyof A as K extends keyof B ? never : K ] : A [ K ]
79- } & B
80-
8176/**
8277 * Unmaps syntax property declarations to a map of { propName: IType }
8378 *
@@ -205,28 +200,23 @@ export interface IModelType<
205200 // so it is recommended to use pre/post process snapshot after all props have been defined
206201 props < PROPS2 extends ModelPropertiesDeclaration > (
207202 props : PROPS2
208- ) : IModelType <
209- OmitMerge < PROPS , ModelPropertiesDeclarationToProperties < PROPS2 > > ,
210- OTHERS ,
211- CustomC ,
212- CustomS
213- >
203+ ) : IModelType < PROPS & ModelPropertiesDeclarationToProperties < PROPS2 > , OTHERS , CustomC , CustomS >
214204
215- views < V extends AnyObject > (
205+ views < V extends Object > (
216206 fn : ( self : Instance < this> ) => V
217- ) : IModelType < PROPS , OmitMerge < OTHERS , V > , CustomC , CustomS >
207+ ) : IModelType < PROPS , OTHERS & V , CustomC , CustomS >
218208
219209 actions < A extends ModelActions > (
220210 fn : ( self : Instance < this> ) => A
221- ) : IModelType < PROPS , OmitMerge < OTHERS , A > , CustomC , CustomS >
211+ ) : IModelType < PROPS , OTHERS & A , CustomC , CustomS >
222212
223- volatile < VS extends AnyObject > (
224- fn : ( self : Instance < this> ) => VS
225- ) : IModelType < PROPS , OmitMerge < OTHERS , VS > , CustomC , CustomS >
213+ volatile < TP extends object > (
214+ fn : ( self : Instance < this> ) => TP
215+ ) : IModelType < PROPS , OTHERS & TP , CustomC , CustomS >
226216
227- extend < A extends ModelActions = { } , V extends AnyObject = { } , VS extends AnyObject = { } > (
217+ extend < A extends ModelActions = { } , V extends Object = { } , VS extends Object = { } > (
228218 fn : ( self : Instance < this> ) => { actions ?: A ; views ?: V ; state ?: VS }
229- ) : IModelType < PROPS , OmitMerge < OTHERS , A & V & VS > , CustomC , CustomS >
219+ ) : IModelType < PROPS , OTHERS & A & V & VS , CustomC , CustomS >
230220
231221 preProcessSnapshot < NewC = ModelCreationType2 < PROPS , CustomC > > (
232222 fn : ( snapshot : NewC ) => WithAdditionalProperties < ModelCreationType2 < PROPS , CustomC > >
@@ -477,7 +467,7 @@ export class ModelType<
477467 return this . cloneAndEnhance ( { properties } )
478468 }
479469
480- volatile < TP extends AnyObject > ( fn : ( self : Instance < this> ) => TP ) {
470+ volatile < TP extends object > ( fn : ( self : Instance < this> ) => TP ) {
481471 if ( typeof fn !== "function" ) {
482472 throw new MstError (
483473 `You passed an ${ typeof fn } to volatile state as an argument, when function is expected`
@@ -514,7 +504,7 @@ export class ModelType<
514504 } )
515505 }
516506
517- extend < A extends ModelActions = { } , V extends AnyObject = { } , VS extends AnyObject = { } > (
507+ extend < A extends ModelActions = { } , V extends Object = { } , VS extends Object = { } > (
518508 fn : ( self : Instance < this> ) => { actions ?: A ; views ?: V ; state ?: VS }
519509 ) {
520510 const initializer = ( self : Instance < this> ) => {
@@ -531,15 +521,15 @@ export class ModelType<
531521 return this . cloneAndEnhance ( { initializers : [ initializer ] } )
532522 }
533523
534- views < V extends AnyObject > ( fn : ( self : Instance < this> ) => V ) {
524+ views < V extends Object > ( fn : ( self : Instance < this> ) => V ) {
535525 const viewInitializer = ( self : Instance < this> ) => {
536526 this . instantiateViews ( self , fn ( self ) )
537527 return self
538528 }
539529 return this . cloneAndEnhance ( { initializers : [ viewInitializer ] } )
540530 }
541531
542- private instantiateViews ( self : this[ "T" ] , views : AnyObject ) : void {
532+ private instantiateViews ( self : this[ "T" ] , views : Object ) : void {
543533 // check views return
544534 if ( ! isPlainObject ( views ) ) {
545535 throw new MstError ( `views initializer should return a plain object containing views` )
0 commit comments