types: make event emitters use mapped event types (#7019)

This commit is contained in:
Suneet Tipirneni
2021-11-23 04:23:14 -05:00
committed by GitHub
parent 802a5ac228
commit 48555cb8eb
2 changed files with 79 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
import type { ChildProcess } from 'child_process';
import type {
APIGuildMember,
APIInteractionGuildMember,
@@ -26,6 +27,7 @@ import {
Client,
ClientApplication,
ClientUser,
CloseEvent,
Collection,
CommandInteraction,
CommandInteractionOption,
@@ -81,6 +83,8 @@ import {
Shard,
ApplicationCommandAutocompleteOption,
ApplicationCommandNumericOptionData,
WebSocketShard,
Collector,
} from '.';
import type { ApplicationCommandOptionTypes } from './enums';
@@ -1124,4 +1128,31 @@ client.on('interactionCreate', async interaction => {
declare const shard: Shard;
shard.on('death', process => {
assertType<ChildProcess>(process);
});
declare const webSocketShard: WebSocketShard;
webSocketShard.on('close', event => {
assertType<CloseEvent>(event);
});
declare const collector: Collector<string, Interaction, string[]>;
collector.on('collect', (collected, ...other) => {
assertType<Interaction>(collected);
assertType<string[]>(other);
});
collector.on('dispose', (vals, ...other) => {
assertType<Interaction>(vals);
assertType<string[]>(other);
});
collector.on('end', (collection, reason) => {
assertType<Collection<string, Interaction>>(collection);
assertType<string>(reason);
});
assertType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));