From 3375646f6062f34c5914892631b5f025855c81bb Mon Sep 17 00:00:00 2001 From: Ben Asher Date: Sat, 6 May 2023 13:02:22 -0700 Subject: [PATCH] Fix is-empty types (#552) --- packages/object-is-empty/index.d.ts | 5 +---- packages/object-is-empty/index.tests.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/object-is-empty/index.d.ts b/packages/object-is-empty/index.d.ts index 09ee61c81..f92199c69 100644 --- a/packages/object-is-empty/index.d.ts +++ b/packages/object-is-empty/index.d.ts @@ -1,13 +1,10 @@ type ReturnTrueValues = null | undefined | "" | [] | number | boolean | Symbol; -type ReturnFalseValues = string | any[]; -type CheckValue = ReturnTrueValues | ReturnFalseValues | object; +type CheckValue = ReturnTrueValues | object | string | any[]; declare function isEmpty( obj: T ): T extends ReturnTrueValues ? true - : T extends ReturnFalseValues - ? false : boolean; export default isEmpty; diff --git a/packages/object-is-empty/index.tests.ts b/packages/object-is-empty/index.tests.ts index 355ead6e0..25047742f 100644 --- a/packages/object-is-empty/index.tests.ts +++ b/packages/object-is-empty/index.tests.ts @@ -6,17 +6,17 @@ import isEmpty from "./index"; const test1: true = isEmpty(null); const test2: true = isEmpty(undefined); const test3: true = isEmpty([]); -const test4: false = isEmpty([1, 2]); -const test5: false = isEmpty("abc"); -const test6: true = isEmpty(""); -const test7: true = isEmpty(0); -const test8: true = isEmpty(1); -const test9: true = isEmpty(true); -const test10: true = isEmpty(false); -const test11: true = isEmpty(Symbol("abc")); -const test12: true = isEmpty(Symbol("")); +const test4: true = isEmpty(""); +const test5: true = isEmpty(0); +const test6: true = isEmpty(1); +const test7: true = isEmpty(true); +const test8: true = isEmpty(false); +const test9: true = isEmpty(Symbol("abc")); +const test10: true = isEmpty(Symbol("")); // Unknown +const test11: boolean = isEmpty([1, 2]); +const test12: boolean = isEmpty("abc"); const test13: boolean = isEmpty({ a: 3, b: 5 }); const test14: boolean = isEmpty(new Set([1, 2, 2])); const test15: boolean = isEmpty(new Map().set("a", 2));