Skip to content

Commit

Permalink
fix: remove unwanted omit type use
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Francis committed Jul 16, 2022
1 parent c68bcda commit bd06ea4
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/Mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,9 @@ export type MockProxy<T> = {
[K in keyof T]: T[K] extends (...args: infer A) => infer B ? CalledWithMock<B, A> : T[K];
} & T;

// Make a type by omitting keys which match Condition
export type OmitType<Base, Condition> = Omit<
Base,
{
[Key in keyof Base]: Base[Key] extends Condition ? never : Key;
}[keyof Base]
>;

export type DeepMockProxy<T> = {
// This supports deep mocks in the else branch
[K in keyof T]: T[K] extends (...args: infer A) => infer B
? CalledWithMock<B, A> & DeepMockProxy<OmitType<T[K], (...args: any) => any>>
: DeepMockProxy<T[K]>;
[K in keyof T]: T[K] extends (...args: infer A) => infer B ? CalledWithMock<B, A> & DeepMockProxy<T[K]> : DeepMockProxy<T[K]>;
} & T;

export interface MockOpts {
Expand Down

0 comments on commit bd06ea4

Please sign in to comment.