Skip to content

Commit

Permalink
test(types): component type check when props is an empty object (#7419)
Browse files Browse the repository at this point in the history
ref #4051
ref #8825
  • Loading branch information
rudyxu1102 committed Aug 28, 2024
1 parent d875de5 commit d6ccce9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages-private/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,26 @@ describe('type inference w/ options API', () => {
})
})

// #4051
describe('type inference w/ empty prop object', () => {
const MyComponent = defineComponent({
props: {},
setup(props) {
return {}
},
render() {},
})
expectType<JSX.Element>(<MyComponent />)
// AllowedComponentProps
expectType<JSX.Element>(<MyComponent class={'foo'} />)
// ComponentCustomProps
expectType<JSX.Element>(<MyComponent custom={1} />)
// VNodeProps
expectType<JSX.Element>(<MyComponent key="1" />)
// @ts-expect-error
expectError(<MyComponent other="other" />)
})

describe('with mixins', () => {
const MixinA = defineComponent({
emits: ['bar'],
Expand Down

0 comments on commit d6ccce9

Please sign in to comment.