types: bump TS version + type test for createComponent
This commit is contained in:
36
packages/runtime-core/__tests__/createComponent.spec.ts
Normal file
36
packages/runtime-core/__tests__/createComponent.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createComponent } from '../src/component'
|
||||
import { value } from '@vue/observer'
|
||||
|
||||
test('createComponent type inference', () => {
|
||||
const MyComponent = createComponent({
|
||||
props: {
|
||||
a: Number,
|
||||
b: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
props.a * 2
|
||||
props.b.slice()
|
||||
return {
|
||||
c: value(1),
|
||||
d: {
|
||||
e: value('hi')
|
||||
}
|
||||
}
|
||||
},
|
||||
render({ state, props }) {
|
||||
state.c * 2
|
||||
state.d.e.slice()
|
||||
props.a * 2
|
||||
props.b.slice()
|
||||
this.a * 2
|
||||
this.b.slice()
|
||||
this.c * 2
|
||||
this.d.e.slice()
|
||||
}
|
||||
})
|
||||
MyComponent // avoid unused
|
||||
// rename this file to .tsx to test TSX props inference
|
||||
// ;(<MyComponent a={1} b="foo"/>)
|
||||
})
|
||||
Reference in New Issue
Block a user