Skip to content

Commit

Permalink
fix(types): optional Boolean props as default props (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-montigny-desautels committed Feb 26, 2022
1 parent b01f1e4 commit 8f88ae6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/component/componentProps.ts
Expand Up @@ -76,7 +76,19 @@ export type ExtractPropTypes<O> = O extends object
: { [K in string]: any }

type DefaultKeys<T> = {
[K in keyof T]: T[K] extends { default: any } ? K : never
[K in keyof T]: T[K] extends
| {
default: any
}
| BooleanConstructor
| { type: BooleanConstructor }
? T[K] extends {
type: BooleanConstructor
required: true
}
? never
: K
: never
}[keyof T]

// extract props which defined with default from prop options
Expand Down

0 comments on commit 8f88ae6

Please sign in to comment.