From 61eab94700bd9c5ac7c7628a52d92a5168b27ef6 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Wed, 23 Oct 2024 20:36:13 +0800 Subject: [PATCH 1/2] fix(types): avoid nullable as keys to affect the inference of `IsKeyValues` --- packages/shared/src/typeUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/typeUtils.ts b/packages/shared/src/typeUtils.ts index f5b9e6ec3c8..6d7d7ea4148 100644 --- a/packages/shared/src/typeUtils.ts +++ b/packages/shared/src/typeUtils.ts @@ -16,7 +16,7 @@ export type IfAny = 0 extends 1 & T ? Y : N export type IsKeyValues = IfAny< T, false, - T extends object ? (keyof T extends K ? true : false) : false + T extends object ? (NonNullable extends K ? true : false) : false > /** From b2c140424cdd6634bf42b4f9a0ad13cd381e3b45 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Thu, 31 Oct 2024 18:15:19 +0800 Subject: [PATCH 2/2] fix: use `PropertyKey` --- packages/shared/src/typeUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/typeUtils.ts b/packages/shared/src/typeUtils.ts index 6d7d7ea4148..dcecfe03532 100644 --- a/packages/shared/src/typeUtils.ts +++ b/packages/shared/src/typeUtils.ts @@ -13,7 +13,7 @@ export type LooseRequired = { [P in keyof (T & Required)]: T[P] } // https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360 export type IfAny = 0 extends 1 & T ? Y : N -export type IsKeyValues = IfAny< +export type IsKeyValues = IfAny< T, false, T extends object ? (NonNullable extends K ? true : false) : false