fix(types): fix typescript error when spreading $props(#5968)

This commit is contained in:
Carlos Rodrigues
2022-05-20 17:59:29 +01:00
committed by GitHub
parent 8071ef47b5
commit 0c7fd13ea6
5 changed files with 27 additions and 7 deletions

View File

@@ -44,6 +44,7 @@ export const Custom = defineComponent({
expectType<JSX.Element>(<Custom baz={1} />)
expectType<JSX.Element>(<Custom custom={1} baz={1} />)
expectType<JSX.Element>(<Custom bar="bar" baz={1} />)
expectType<JSX.Element>(<Custom ref={''} bar="bar" baz={1} />)
// @ts-expect-error
expectType<JSX.Element>(<Custom />)

View File

@@ -1144,6 +1144,25 @@ describe('DefineComponent should infer correct types when assigning to Component
expectType<Component>(component)
})
// #5969
describe('should allow to assign props', () => {
const Child = defineComponent({
props: {
bar: String
}
})
const Parent = defineComponent({
props: {
...Child.props,
foo: String
}
})
const child = new Child()
expectType<JSX.Element>(<Parent {...child.$props} />)
})
// check if defineComponent can be exported
export default {
// function components