Skip to content

Commit

Permalink
fix(types): expose emits as props in functional components (#9234)
Browse files Browse the repository at this point in the history
  • Loading branch information
blake-newman authored Nov 30, 2023
1 parent ad27473 commit 887e54c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dts-test/functionalComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Bar.emits = {
Bar.emits = { baz: () => void 0 }

// TSX
expectType<JSX.Element>(<Bar foo={1} />)
expectType<JSX.Element>(<Bar foo={1} onUpdate={() => {}} />)
// @ts-expect-error
;<Foo />
// @ts-expect-error
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import {
ObjectEmitsOptions,
EmitFn,
emit,
normalizeEmitsOptions
normalizeEmitsOptions,
EmitsToProps
} from './componentEmits'
import {
EMPTY_OBJ,
Expand Down Expand Up @@ -131,7 +132,7 @@ export interface FunctionalComponent<
> extends ComponentInternalOptions {
// use of any here is intentional so it can be a valid JSX Element constructor
(
props: P,
props: P & EmitsToProps<E>,
ctx: Omit<SetupContext<E, IfAny<S, {}, SlotsType<S>>>, 'expose'>
): any
props?: ComponentPropsOptions<P>
Expand Down

0 comments on commit 887e54c

Please sign in to comment.