Skip to content

Commit

Permalink
[ts] Make type definitions compatible with TypeScript 3.9 (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfmio authored May 12, 2020
1 parent 5f89ad3 commit 2544564
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,16 @@ declare namespace EventEmitter {
>(): EventEmitter<EventTypes, Context>;
}

export type ValidEventTypes<T = any> = string | symbol | T extends {
[K in keyof T]: any[] | ((...args: any[]) => void);
}
? T
: never;
export type ValidEventTypes =
| string
| symbol
| { [K in string | symbol]: any[] | ((...args: any[]) => void) };

export type EventNames<T extends ValidEventTypes> = T extends string | symbol
? T
: keyof T;

export type ArgumentMap<T> = {
export type ArgumentMap<T extends object> = {
[K in keyof T]: T[K] extends (...args: any[]) => void
? Parameters<T[K]>
: T[K] extends any[]
Expand All @@ -114,7 +113,7 @@ declare namespace EventEmitter {
K extends EventNames<T>
> = T extends string | symbol
? (...args: any[]) => void
: (...args: ArgumentMap<T>[K]) => void;
: (...args: ArgumentMap<Exclude<T, string | symbol>>[K]) => void;

export type EventArgs<
T extends ValidEventTypes,
Expand Down

0 comments on commit 2544564

Please sign in to comment.