Skip to content

Commit

Permalink
fix(types): EmitsOptions support named tuple syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jan 9, 2025
1 parent 22dcbf3 commit 5d549d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages-private/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,20 @@ describe('function syntax w/ emits', () => {
},
},
)

defineComponent<
{},
{
update: [value: string] // named tuple syntax
}
>((props, ctx) => {
ctx.emit('update', '123')
// @ts-expect-error
ctx.emit('update', 123)
// @ts-expect-error
ctx.emit('non-exist')
return () => {}
})
})

describe('function syntax w/ runtime props', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import type { ComponentPublicInstance } from './componentPublicInstance'

export type ObjectEmitsOptions = Record<
string,
((...args: any[]) => any) | null
((...args: any[]) => any) | null | any[]
>

export type EmitsOptions = ObjectEmitsOptions | string[]
Expand Down

0 comments on commit 5d549d2

Please sign in to comment.