types(defineComponent): fix optional Boolean prop types (#2401)
fix #2338
This commit is contained in:
@@ -198,3 +198,29 @@ describe('component w/ props w/ default value', () => {
|
||||
|
||||
h(MyComponent, {})
|
||||
})
|
||||
|
||||
// #2338
|
||||
describe('Boolean prop implicit false', () => {
|
||||
const MyComponent = defineComponent({
|
||||
props: {
|
||||
visible: Boolean
|
||||
}
|
||||
})
|
||||
|
||||
h(MyComponent, {})
|
||||
|
||||
const RequiredComponent = defineComponent({
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
h(RequiredComponent, {
|
||||
visible: true
|
||||
})
|
||||
// @ts-expect-error
|
||||
expectError(h(RequiredComponent, {}))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user