Skip to content

Commit 887e54c

Browse files
authored
fix(types): expose emits as props in functional components (#9234)
1 parent ad27473 commit 887e54c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/dts-test/functionalComponent.test-d.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Bar.emits = {
4545
Bar.emits = { baz: () => void 0 }
4646

4747
// TSX
48-
expectType<JSX.Element>(<Bar foo={1} />)
48+
expectType<JSX.Element>(<Bar foo={1} onUpdate={() => {}} />)
4949
// @ts-expect-error
5050
;<Foo />
5151
// @ts-expect-error

packages/runtime-core/src/component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ import {
5050
ObjectEmitsOptions,
5151
EmitFn,
5252
emit,
53-
normalizeEmitsOptions
53+
normalizeEmitsOptions,
54+
EmitsToProps
5455
} from './componentEmits'
5556
import {
5657
EMPTY_OBJ,
@@ -131,7 +132,7 @@ export interface FunctionalComponent<
131132
> extends ComponentInternalOptions {
132133
// use of any here is intentional so it can be a valid JSX Element constructor
133134
(
134-
props: P,
135+
props: P & EmitsToProps<E>,
135136
ctx: Omit<SetupContext<E, IfAny<S, {}, SlotsType<S>>>, 'expose'>
136137
): any
137138
props?: ComponentPropsOptions<P>

0 commit comments

Comments
 (0)