From 15bce60f581ce5b404182c84a29c97c0d0e0baa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Rom=C3=A1n?= Date: Sun, 9 May 2021 19:47:21 +0200 Subject: [PATCH 1/4] fix(Types): make event listeners accept unknown-returned cb --- typings/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 77fbcddff482..ff17271a14d4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -311,25 +311,25 @@ declare module 'discord.js' { public sweepMessages(lifetime?: number): number; public toJSON(): object; - public on(event: K, listener: (...args: ClientEvents[K]) => void): this; + public on(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public on( event: Exclude, - listener: (...args: any[]) => void, + listener: (...args: any[]) => unknown, ): this; - public once(event: K, listener: (...args: ClientEvents[K]) => void): this; + public once(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public once( event: Exclude, - listener: (...args: any[]) => void, + listener: (...args: any[]) => unknown, ): this; public emit(event: K, ...args: ClientEvents[K]): boolean; public emit(event: Exclude, ...args: any[]): boolean; - public off(event: K, listener: (...args: ClientEvents[K]) => void): this; + public off(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public off( event: Exclude, - listener: (...args: any[]) => void, + listener: (...args: any[]) => unknown, ): this; public removeAllListeners(event?: K): this; From 5f4a3395c2518fb7f77467a840c4bd8daa675826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Rom=C3=A1n?= Date: Sun, 9 May 2021 22:12:26 +0200 Subject: [PATCH 2/4] fix(Types): use `void | Promise` over `unknown` --- typings/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index ff17271a14d4..94208cd31f3f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -311,25 +311,25 @@ declare module 'discord.js' { public sweepMessages(lifetime?: number): number; public toJSON(): object; - public on(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public on(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; public on( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => void | Promise, ): this; - public once(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public once(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; public once( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => void | Promise, ): this; public emit(event: K, ...args: ClientEvents[K]): boolean; public emit(event: Exclude, ...args: any[]): boolean; - public off(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public off(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; public off( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => void | Promise, ): this; public removeAllListeners(event?: K): this; From b254be915042182a2889c5bc854bf43ec9235708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Rom=C3=A1n?= Date: Sun, 9 May 2021 22:23:20 +0200 Subject: [PATCH 3/4] revert: fix 5f4a339 TSLint does not allow void | Promise --- typings/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 94208cd31f3f..ff17271a14d4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -311,25 +311,25 @@ declare module 'discord.js' { public sweepMessages(lifetime?: number): number; public toJSON(): object; - public on(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; + public on(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public on( event: Exclude, - listener: (...args: any[]) => void | Promise, + listener: (...args: any[]) => unknown, ): this; - public once(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; + public once(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public once( event: Exclude, - listener: (...args: any[]) => void | Promise, + listener: (...args: any[]) => unknown, ): this; public emit(event: K, ...args: ClientEvents[K]): boolean; public emit(event: Exclude, ...args: any[]): boolean; - public off(event: K, listener: (...args: ClientEvents[K]) => void | Promise): this; + public off(event: K, listener: (...args: ClientEvents[K]) => unknown): this; public off( event: Exclude, - listener: (...args: any[]) => void | Promise, + listener: (...args: any[]) => unknown, ): this; public removeAllListeners(event?: K): this; From 8c840434b7e29786801e4e4276f0688d5e129b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Rom=C3=A1n?= Date: Sun, 9 May 2021 23:45:10 +0200 Subject: [PATCH 4/4] fix(Types): use Awaited --- typings/index.d.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index ff17271a14d4..5e12d8f07806 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -43,6 +43,8 @@ declare enum StickerFormatTypes { LOTTIE = 3, } +type Awaited = T | Promise; + declare module 'discord.js' { import BaseCollection from '@discordjs/collection'; import { ChildProcess } from 'child_process'; @@ -311,25 +313,25 @@ declare module 'discord.js' { public sweepMessages(lifetime?: number): number; public toJSON(): object; - public on(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public on(event: K, listener: (...args: ClientEvents[K]) => Awaited): this; public on( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => Awaited, ): this; - public once(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public once(event: K, listener: (...args: ClientEvents[K]) => Awaited): this; public once( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => Awaited, ): this; public emit(event: K, ...args: ClientEvents[K]): boolean; public emit(event: Exclude, ...args: any[]): boolean; - public off(event: K, listener: (...args: ClientEvents[K]) => unknown): this; + public off(event: K, listener: (...args: ClientEvents[K]) => Awaited): this; public off( event: Exclude, - listener: (...args: any[]) => unknown, + listener: (...args: any[]) => Awaited, ): this; public removeAllListeners(event?: K): this;