parent
6aa2256913
commit
5dbd6b36a0
@ -28,8 +28,8 @@ export type EmitsOptions = ObjectEmitsOptions | string[]
|
|||||||
export type EmitFn<
|
export type EmitFn<
|
||||||
Options = ObjectEmitsOptions,
|
Options = ObjectEmitsOptions,
|
||||||
Event extends keyof Options = keyof Options
|
Event extends keyof Options = keyof Options
|
||||||
> = Options extends any[]
|
> = Options extends Array<infer V>
|
||||||
? (event: Options[0], ...args: any[]) => void
|
? (event: V, ...args: any[]) => void
|
||||||
: {} extends Options // if the emit is empty object (usually the default value for emit) should be converted to function
|
: {} extends Options // if the emit is empty object (usually the default value for emit) should be converted to function
|
||||||
? (event: string, ...args: any[]) => void
|
? (event: string, ...args: any[]) => void
|
||||||
: UnionToIntersection<
|
: UnionToIntersection<
|
||||||
|
@ -63,3 +63,12 @@ const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expectType<Component>(Baz)
|
expectType<Component>(Baz)
|
||||||
|
|
||||||
|
const Qux: FunctionalComponent<{}, ['foo', 'bar']> = (props, { emit }) => {
|
||||||
|
emit('foo')
|
||||||
|
emit('foo', 1, 2)
|
||||||
|
emit('bar')
|
||||||
|
emit('bar', 1, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectType<Component>(Qux)
|
||||||
|
Loading…
Reference in New Issue
Block a user