Skip to content

Commit d6ccce9

Browse files
authored
test(types): component type check when props is an empty object (#7419)
ref #4051 ref #8825
1 parent d875de5 commit d6ccce9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: packages-private/dts-test/defineComponent.test-d.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,26 @@ describe('type inference w/ options API', () => {
480480
})
481481
})
482482

483+
// #4051
484+
describe('type inference w/ empty prop object', () => {
485+
const MyComponent = defineComponent({
486+
props: {},
487+
setup(props) {
488+
return {}
489+
},
490+
render() {},
491+
})
492+
expectType<JSX.Element>(<MyComponent />)
493+
// AllowedComponentProps
494+
expectType<JSX.Element>(<MyComponent class={'foo'} />)
495+
// ComponentCustomProps
496+
expectType<JSX.Element>(<MyComponent custom={1} />)
497+
// VNodeProps
498+
expectType<JSX.Element>(<MyComponent key="1" />)
499+
// @ts-expect-error
500+
expectError(<MyComponent other="other" />)
501+
})
502+
483503
describe('with mixins', () => {
484504
const MixinA = defineComponent({
485505
emits: ['bar'],

0 commit comments

Comments
 (0)