fix(types): make return type of defineComponent assignable to Component type (#1032)

fix #993
This commit is contained in:
Carlos Rodrigues
2020-04-24 18:22:58 +01:00
committed by GitHub
parent 28b4c317b4
commit f3a9b516bd
4 changed files with 49 additions and 10 deletions

View File

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