test: improve tests and typing for runtime-core (#100)

* test: add test case for declaring Array prop type with constructor casting in `createComponent`

* test: add test case for `setup(props)` with explicit props declaration
This commit is contained in:
Carlos Rodrigues
2019-10-05 20:37:55 +01:00
committed by Evan You
parent f48a2ffc76
commit 8133b3867a
4 changed files with 46 additions and 6 deletions

View File

@@ -22,10 +22,17 @@ test('createComponent type inference', () => {
default: 'hello'
},
// explicit type casting
cc: (Array as any) as PropType<string[]>,
cc: Array as PropType<string[]>,
// required + type casting
dd: {
type: (Array as any) as PropType<string[]>,
type: Array as PropType<string[]>,
required: true
},
// explicit type casting with constructor
ccc: Array as () => string[],
// required + contructor type casting
ddd: {
type: Array as () => string[],
required: true
}
} as const, // required to narrow for conditional check
@@ -60,7 +67,7 @@ test('createComponent type inference', () => {
}
})
// test TSX props inference
;(<MyComponent a={1} b="foo" dd={['foo']}/>)
;(<MyComponent a={1} b="foo" dd={['foo']} ddd={['foo']}/>)
})
test('type inference w/ optional props declaration', () => {