From 0995db5eb9d198989d3582a03670d8797d3b1701 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Fri, 23 Apr 2021 16:30:37 +0800 Subject: [PATCH 1/2] feat: support renaming for props --- packages/runtime-core/src/componentProps.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 0238bf80e28..f4bda31b7d6 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -104,7 +104,8 @@ type InferPropType = [T] extends [null] : T export type ExtractPropTypes = O extends object - ? { [K in RequiredKeys]: InferPropType } & + ? { [K in keyof O]?: unknown } & + { [K in RequiredKeys]: InferPropType } & { [K in OptionalKeys]?: InferPropType } : { [K in string]: any } From d7ad83e350a79ad8d509bedd0d1c6fcc076597cf Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Fri, 23 Apr 2021 17:16:33 +0800 Subject: [PATCH 2/2] chore: comment for `[K in keyof O]` --- packages/runtime-core/src/componentProps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index f4bda31b7d6..7d999a3c168 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -104,7 +104,7 @@ type InferPropType = [T] extends [null] : T export type ExtractPropTypes = O extends object - ? { [K in keyof O]?: unknown } & + ? { [K in keyof O]?: unknown } & // This is needed to keep the relation between the option prop and the props, allowing to use ctrl+click to navigate to the prop options. see: #3656 { [K in RequiredKeys]: InferPropType } & { [K in OptionalKeys]?: InferPropType } : { [K in string]: any }