export type EmitFn<
Options = ObjectEmitsOptions,
Event extends keyof Options = keyof Options
-> = Options extends any[]
- ? (event: Options[0], ...args: any[]) => void
+> = Options extends Array<infer V>
+ ? (event: V, ...args: any[]) => void
: {} extends Options // if the emit is empty object (usually the default value for emit) should be converted to function
? (event: string, ...args: any[]) => void
: UnionToIntersection<
}
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)