Skip to content

Commit

Permalink
Fix equal() type (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse authored Feb 8, 2022
1 parent fb38df0 commit 45b8c83
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ type Class<T = any> = new (...args: any[]) => T;

type UnpackArray<T> = T extends (infer U)[] ? U : T;

type RecursivePartial<T> = {
type RecursivePartial<T> = T extends object ? {
[P in keyof T]?:
T[P] extends (infer U)[] ? RecursivePartial<U>[] :
T[P] extends object ? RecursivePartial<T[P]> :
T[P];
};
T[P] extends Array<infer I> ? Array<RecursivePartial<I>> :
RecursivePartial<T[P]>;
} : T;

type Loosely<T> = T extends object ? RecursivePartial<T> & { [key: string]: any } : T;

Expand Down Expand Up @@ -348,7 +347,7 @@ declare namespace expect {
*
* @returns assertion chain object.
*/
equal(value: Loosely<T>, options?: Hoek.deepEqual.Options): Assertion<T>;
equal(value: RecursivePartial<T>, options?: Hoek.deepEqual.Options): Assertion<T>;

/**
* Asserts that the reference value equals the provided value.
Expand All @@ -358,7 +357,7 @@ declare namespace expect {
*
* @returns assertion chain object.
*/
equals(value: Loosely<T>, options?: Hoek.deepEqual.Options): Assertion<T>;
equals(value: RecursivePartial<T>, options?: Hoek.deepEqual.Options): Assertion<T>;

/**
* Asserts that the reference value has the provided instanceof value.
Expand Down

0 comments on commit 45b8c83

Please sign in to comment.