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

@@ -19,6 +19,7 @@ describe('with object props', () => {
a?: number | undefined
b: string
e?: Function
h: boolean
bb: string
bbb: string
cc?: string[] | undefined
@@ -46,6 +47,7 @@ describe('with object props', () => {
required: true
},
e: Function,
h: Boolean,
// default value should infer type and make it non-void
bb: {
default: 'hello'
@@ -108,6 +110,7 @@ describe('with object props', () => {
expectType<ExpectedProps['a']>(props.a)
expectType<ExpectedProps['b']>(props.b)
expectType<ExpectedProps['e']>(props.e)
expectType<ExpectedProps['h']>(props.h)
expectType<ExpectedProps['bb']>(props.bb)
expectType<ExpectedProps['bbb']>(props.bbb)
expectType<ExpectedProps['cc']>(props.cc)
@@ -142,6 +145,7 @@ describe('with object props', () => {
expectType<ExpectedProps['a']>(props.a)
expectType<ExpectedProps['b']>(props.b)
expectType<ExpectedProps['e']>(props.e)
expectType<ExpectedProps['h']>(props.h)
expectType<ExpectedProps['bb']>(props.bb)
expectType<ExpectedProps['cc']>(props.cc)
expectType<ExpectedProps['dd']>(props.dd)
@@ -161,6 +165,7 @@ describe('with object props', () => {
expectType<ExpectedProps['a']>(this.a)
expectType<ExpectedProps['b']>(this.b)
expectType<ExpectedProps['e']>(this.e)
expectType<ExpectedProps['h']>(this.h)
expectType<ExpectedProps['bb']>(this.bb)
expectType<ExpectedProps['cc']>(this.cc)
expectType<ExpectedProps['dd']>(this.dd)