Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type definitions compatible with Typescript 3.9 #226

Merged
merged 7 commits into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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