feat(types): simplify ExtractPropTypes to avoid props JSDocs being removed (#5166)

This commit is contained in:
Johnson Chu 2021-12-25 15:52:22 +08:00 committed by GitHub
parent e373b0bbe2
commit a570b38741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,11 +120,13 @@ type InferPropType<T> = [T] extends [null]
: V : V
: T : T
export type ExtractPropTypes<O> = O extends object export type ExtractPropTypes<O> = {
? { [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 // use `keyof Pick<O, RequiredKeys<O>>` instead of `RequiredKeys<O>` to support IDE features
{ [K in RequiredKeys<O>]: InferPropType<O[K]> } & [K in keyof Pick<O, RequiredKeys<O>>]: InferPropType<O[K]>
{ [K in OptionalKeys<O>]?: InferPropType<O[K]> } } & {
: { [K in string]: any } // 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 { const enum BooleanFlags {
shouldCast, shouldCast,