From a570b38741a7dc259772c5ccce7ea8a1638eb0bd Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Sat, 25 Dec 2021 15:52:22 +0800 Subject: [PATCH] feat(types): simplify `ExtractPropTypes` to avoid props JSDocs being removed (#5166) --- packages/runtime-core/src/componentProps.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index cf73261f..dbd54539 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -120,11 +120,13 @@ type InferPropType = [T] extends [null] : V : T -export type ExtractPropTypes = O extends object - ? { [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 } +export type ExtractPropTypes = { + // use `keyof Pick>` instead of `RequiredKeys` to support IDE features + [K in keyof Pick>]: InferPropType +} & { + // use `keyof Pick>` instead of `OptionalKeys` to support IDE features + [K in keyof Pick>]?: InferPropType +} const enum BooleanFlags { shouldCast,