Skip to content

Commit

Permalink
fix(types): optional Boolean prop types #636 (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
almost-no-one committed Apr 18, 2021
1 parent 7955e28 commit a081227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/component/componentProps.ts
Expand Up @@ -27,7 +27,13 @@ type PropConstructor<T> =
| { new (...args: string[]): Function }

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

type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>
Expand Down
1 change: 0 additions & 1 deletion test-dts/defineComponent.test-d.ts
Expand Up @@ -85,7 +85,6 @@ describe('with object props', () => {
},
hhh: {
type: Boolean,
required: true,
},
// default + function
ffff: {
Expand Down

0 comments on commit a081227

Please sign in to comment.