1- import { AllArguments } from './Arguments' ;
1+ import type { AllArguments } from './Arguments' ;
2+ import type { ClearType , FirstLevelMethod } from './Types' ;
23
34type FunctionSubstituteWithOverloads < TFunc , Terminating = false > =
45 TFunc extends {
@@ -66,13 +67,6 @@ type MockObjectMixin<TArguments extends any[], TReturnType> = BaseMockObjectMixi
6667 mimicks : OneArgumentRequiredFunction < ( ...args : TArguments ) => TReturnType , void > ;
6768}
6869
69- export type ObjectSubstitute < T extends Object , K extends Object = T > = ObjectSubstituteTransformation < T > & {
70- received ( amount ?: number ) : TerminatingObject < K > ;
71- didNotReceive ( ) : TerminatingObject < K > ;
72- mimick ( instance : T ) : void ;
73- clearSubstitute ( clearType ?: ClearType ) : void ;
74- }
75-
7670type TerminatingFunction < TArguments extends any [ ] > = ( ( ...args : TArguments ) => void ) & ( ( arg : AllArguments < TArguments > ) => void )
7771
7872type TerminatingObject < T > = {
@@ -83,16 +77,19 @@ type TerminatingObject<T> = {
8377 T [ P ] ;
8478}
8579
86- type ObjectSubstituteTransformation < T extends Object > = {
80+ type ObjectSubstituteTransformation < K , T = OmitProxyMethods < K > > = {
8781 [ P in keyof T ] :
8882 T [ P ] extends ( ...args : infer F ) => infer R ?
8983 F extends [ ] ? NoArgumentFunctionSubstitute < R > :
9084 FunctionSubstituteWithOverloads < T [ P ] > :
9185 PropertySubstitute < T [ P ] > ;
9286}
9387
94- type Omit < T , K extends keyof any > = Pick < T , Exclude < keyof T , K > > ;
95-
96- export type ClearType = 'all' | 'receivedCalls' | 'substituteValues' ;
97- export type OmitProxyMethods < T extends any > = Omit < T , 'mimick' | 'received' | 'didNotReceive' | 'clearSubstitute' > ;
98- export type DisabledSubstituteObject < T > = T extends ObjectSubstitute < OmitProxyMethods < infer K > , infer K > ? K : never ;
88+ export type OmitProxyMethods < T > = Omit < T , FirstLevelMethod > ;
89+ export type ObjectSubstitute < T > = ObjectSubstituteTransformation < T > & {
90+ received ( amount ?: number ) : TerminatingObject < T > ;
91+ didNotReceive ( ) : TerminatingObject < T > ;
92+ mimick ( instance : OmitProxyMethods < T > ) : void ;
93+ clearSubstitute ( clearType ?: ClearType ) : void ;
94+ }
95+ export type DisabledSubstituteObject < T > = T extends ObjectSubstitute < infer K > ? K : never ;
0 commit comments