Skip to content

Commit

Permalink
feat(types): simplify ExtractPropTypes to avoid props JSDocs being …
Browse files Browse the repository at this point in the history
…removed (#5166)
  • Loading branch information
johnsoncodehk committed Dec 25, 2021
1 parent e373b0b commit a570b38
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/runtime-core/src/componentProps.ts
Expand Up @@ -120,11 +120,13 @@ type InferPropType<T> = [T] extends [null]
: V
: T

export type ExtractPropTypes<O> = 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<O>]: InferPropType<O[K]> } &
{ [K in OptionalKeys<O>]?: InferPropType<O[K]> }
: { [K in string]: any }
export type ExtractPropTypes<O> = {
// use `keyof Pick<O, RequiredKeys<O>>` instead of `RequiredKeys<O>` to support IDE features
[K in keyof Pick<O, RequiredKeys<O>>]: InferPropType<O[K]>
} & {
// use `keyof Pick<O, OptionalKeys<O>>` instead of `OptionalKeys<O>` to support IDE features
[K in keyof Pick<O, OptionalKeys<O>>]?: InferPropType<O[K]>
}

const enum BooleanFlags {
shouldCast,
Expand Down

0 comments on commit a570b38

Please sign in to comment.