types(defineComponent): fix optional Boolean prop types (#2401)

fix #2338
This commit is contained in:
Carlos Rodrigues
2020-10-19 22:25:55 +01:00
committed by GitHub
parent 8e5cdc0d0e
commit d9ad45ad6c
3 changed files with 48 additions and 2 deletions

View File

@@ -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, {}))
})