Skip to content

Commit a570b38

Browse files
feat(types): simplify ExtractPropTypes to avoid props JSDocs being removed (#5166)
1 parent e373b0b commit a570b38

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/runtime-core/src/componentProps.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ type InferPropType<T> = [T] extends [null]
120120
: V
121121
: T
122122

123-
export type ExtractPropTypes<O> = O extends object
124-
? { [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
125-
{ [K in RequiredKeys<O>]: InferPropType<O[K]> } &
126-
{ [K in OptionalKeys<O>]?: InferPropType<O[K]> }
127-
: { [K in string]: any }
123+
export type ExtractPropTypes<O> = {
124+
// use `keyof Pick<O, RequiredKeys<O>>` instead of `RequiredKeys<O>` to support IDE features
125+
[K in keyof Pick<O, RequiredKeys<O>>]: InferPropType<O[K]>
126+
} & {
127+
// use `keyof Pick<O, OptionalKeys<O>>` instead of `OptionalKeys<O>` to support IDE features
128+
[K in keyof Pick<O, OptionalKeys<O>>]?: InferPropType<O[K]>
129+
}
128130

129131
const enum BooleanFlags {
130132
shouldCast,

0 commit comments

Comments
 (0)