From 17059c7021c1e0f454f084602787b3dcd1f685b1 Mon Sep 17 00:00:00 2001 From: Christopher Fox Date: Fri, 1 Dec 2023 13:27:03 -0500 Subject: [PATCH] feat: Support for bigint on sort/sortBy/sortByKey --- src/array.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/array.test.ts b/src/array.test.ts index 0acd3cd..9bf5af5 100644 --- a/src/array.test.ts +++ b/src/array.test.ts @@ -18,6 +18,12 @@ describe("array", () => { it("sorts using specified the specified function", () => { expect([1, 2, 3].sortBy((n: number) => -n)).toEqual([3, 2, 1]); }); + + it("works for bigint fields", () => { + // Using `any` here as an easy case for the compiler not being able to catch the error + const foos: { foo: bigint }[] = [{ foo: 3n }, { foo: -1n }, { foo: 2n }]; + expect(foos.sortBy((f) => f.foo)).toEqual([{ foo: -1n }, { foo: 2n }, { foo: 3n }]); + }); }); describe("sortByKey", () => {