fix(types): fix using tuple type as EmitsOptions (#2160)

fix #2159
This commit is contained in:
wonderful-panda
2020-09-22 23:05:37 +09:00
committed by GitHub
parent 6aa2256913
commit 5dbd6b36a0
2 changed files with 11 additions and 2 deletions

View File

@@ -28,8 +28,8 @@ export type EmitsOptions = ObjectEmitsOptions | string[]
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<