fix(types): expose emits as props in functional components (#9234)

This commit is contained in:
Blake Newman 2023-11-30 18:37:51 +00:00 committed by GitHub
parent ad27473701
commit 887e54c347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -50,7 +50,8 @@ import {
ObjectEmitsOptions,
EmitFn,
emit,
normalizeEmitsOptions
normalizeEmitsOptions,
EmitsToProps
} from './componentEmits'
import {
EMPTY_OBJ,
@ -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>