Skip to content

Commit a081227

Browse files
fix(types): optional Boolean prop types #636 (#678)
1 parent 7955e28 commit a081227

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/component/componentProps.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ type PropConstructor<T> =
2727
| { new (...args: string[]): Function }
2828

2929
type RequiredKeys<T> = {
30-
[K in keyof T]: T[K] extends { required: true } | { default: any } ? K : never
30+
[K in keyof T]: T[K] extends
31+
| { required: true }
32+
| { default: any }
33+
| BooleanConstructor
34+
| { type: BooleanConstructor }
35+
? K
36+
: never
3137
}[keyof T]
3238

3339
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>

test-dts/defineComponent.test-d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ describe('with object props', () => {
8585
},
8686
hhh: {
8787
type: Boolean,
88-
required: true,
8988
},
9089
// default + function
9190
ffff: {

0 commit comments

Comments
 (0)