fix(types): make return type of defineComponent assignable to Component type (#1032)
fix #993
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { expectError } from 'tsd'
|
||||
import { expectError, expectAssignable } from 'tsd'
|
||||
import {
|
||||
describe,
|
||||
h,
|
||||
@@ -131,3 +131,34 @@ describe('h support for generic component type', () => {
|
||||
}
|
||||
foo({})
|
||||
})
|
||||
|
||||
// #993
|
||||
describe('describeComponent extends Component', () => {
|
||||
// functional
|
||||
expectAssignable<Component>(
|
||||
defineComponent((_props: { foo?: string; bar: number }) => {})
|
||||
)
|
||||
|
||||
// typed props
|
||||
expectAssignable<Component>(defineComponent({}))
|
||||
|
||||
// prop arrays
|
||||
expectAssignable<Component>(
|
||||
defineComponent({
|
||||
props: ['a', 'b']
|
||||
})
|
||||
)
|
||||
|
||||
// prop object
|
||||
expectAssignable<Component>(
|
||||
defineComponent({
|
||||
props: {
|
||||
foo: String,
|
||||
bar: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user