File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -69,11 +69,13 @@ type InferPropType<T> = T extends null
69
69
: ExtractCorrectPropType < V >
70
70
: T
71
71
72
- export type ExtractPropTypes < O > = O extends object
73
- ? { [ K in RequiredKeys < O > ] : InferPropType < O [ K ] > } & {
74
- [ K in OptionalKeys < O > ] ?: InferPropType < O [ K ] >
75
- }
76
- : { [ K in string ] : any }
72
+ export type ExtractPropTypes < O > = {
73
+ // use `keyof Pick<O, RequiredKeys<O>>` instead of `RequiredKeys<O>` to support IDE features
74
+ [ K in keyof Pick < O , RequiredKeys < O > > ] : InferPropType < O [ K ] >
75
+ } & {
76
+ // use `keyof Pick<O, OptionalKeys<O>>` instead of `OptionalKeys<O>` to support IDE features
77
+ [ K in keyof Pick < O , OptionalKeys < O > > ] ?: InferPropType < O [ K ] >
78
+ }
77
79
78
80
type DefaultKeys < T > = {
79
81
[ K in keyof T ] : T [ K ] extends
@@ -93,5 +95,6 @@ type DefaultKeys<T> = {
93
95
94
96
// extract props which defined with default from prop options
95
97
export type ExtractDefaultPropTypes < O > = O extends object
96
- ? { [ K in DefaultKeys < O > ] : InferPropType < O [ K ] > }
98
+ ? // use `keyof Pick<O, DefaultKeys<O>>` instead of `DefaultKeys<O>` to support IDE features
99
+ { [ K in keyof Pick < O , DefaultKeys < O > > ] : InferPropType < O [ K ] > }
97
100
: { }
You can’t perform that action at this time.
0 commit comments