fix(types): fix typescript error when spreading $props(#5968)
This commit is contained in:
@@ -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 />)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user