From 67536ee06053b3a467a10a59a85f40828a16f07b Mon Sep 17 00:00:00 2001 From: RicardoErii <‘1974364190@qq.com’> Date: Thu, 4 Jan 2024 21:28:14 +0800 Subject: [PATCH] fix(types): optimizing type inference with defaults --- packages/runtime-core/src/apiSetupHelpers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/apiSetupHelpers.ts b/packages/runtime-core/src/apiSetupHelpers.ts index e5f79444da0..d2d126dc667 100644 --- a/packages/runtime-core/src/apiSetupHelpers.ts +++ b/packages/runtime-core/src/apiSetupHelpers.ts @@ -300,7 +300,9 @@ type PropsWithDefaults< Defaults extends InferDefaults, BKeys extends keyof T, > = Readonly> & { - readonly [K in keyof Defaults]-?: K extends keyof T + readonly [K in keyof Defaults as K extends keyof T + ? K + : never]-?: K extends keyof T ? Defaults[K] extends undefined ? T[K] : NotUndefined