refactor: use interfaces for AsyncEventEmitter event maps (#10044)

* refactor: use interfaces for AsyncEventEmitter event maps

* refactor: apply suggestions from code review and add tests

* refactor: better errors on missing dispatch types
This commit is contained in:
Qjuh
2023-12-14 17:09:13 +01:00
committed by GitHub
parent f2138bb5a8
commit adfd9cd3b3
11 changed files with 102 additions and 66 deletions

View File

@@ -18,7 +18,7 @@ import { RequestMethod } from './utils/types.js';
import type {
RESTOptions,
ResponseLike,
RestEventsMap,
RestEvents,
HashData,
InternalRequest,
RouteLike,
@@ -31,7 +31,7 @@ import { isBufferLike, parseResponse } from './utils/utils.js';
/**
* Represents the class that manages handlers for endpoints
*/
export class REST extends AsyncEventEmitter<RestEventsMap> {
export class REST extends AsyncEventEmitter<RestEvents> {
/**
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
* performed by this manager.

View File

@@ -14,9 +14,7 @@ export interface RestEvents {
restDebug: [info: string];
}
export type RestEventsMap = {
[K in keyof RestEvents]: RestEvents[K];
};
export interface RestEventsMap extends RestEvents {}
/**
* Options to be passed when creating the REST instance