Skip to content

Commit

Permalink
Simplifies typings on just-compare (#480)
Browse files Browse the repository at this point in the history
* Simplifies typings on `just-compare`

* remove all the TS tests which are now fine
  • Loading branch information
neil-morrison44 authored Aug 7, 2022
1 parent 64f923f commit ee4d7cd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
16 changes: 1 addition & 15 deletions packages/collection-compare/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Definitions by: Justy Robles <https://github.com/justyrobles>

type Primitive = boolean | string | number | bigint | null | undefined;

declare function compare<T extends Primitive>(value1: T, value2: T): boolean;

declare function compare<T1 extends object, T2 extends object & T1>(
value1: T1,
value2: T2
): boolean;

declare function compare<T1 extends object & T2, T2 extends object>(
value1: T1,
value2: T2
): boolean;
declare function compare(value1: unknown, value2: unknown): boolean;

export default compare;
24 changes: 0 additions & 24 deletions packages/collection-compare/index.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,3 @@ const compareIt = <T extends object>(a: T, b: T) => compare(a, b);
// Not okay
// @ts-expect-error
compare();
// @ts-expect-error
compare(1, "1");
// @ts-expect-error
compare(["abc"], "abc");
// @ts-expect-error
compare({ a: 1, b: 2 }, [{ a: 1, b: 2 }]);
// @ts-expect-error
compare(obj2, obj1);
// @ts-expect-error
compare(obj1, obj2);
// @ts-expect-error
compare(obj1, num1);
// @ts-expect-error
compare(num1, obj1);
// @ts-expect-error
compare(NaN, "abc");
// @ts-expect-error
compare(funcA, funcB);
// @ts-expect-error
compare(funcA, true);
// @ts-expect-error
compare(num1, num2);
// @ts-expect-error
compare(num2, num1);

0 comments on commit ee4d7cd

Please sign in to comment.