I've got an interface representing the arguments (along with their types) passed to a listener for each event type
export interface ClientEvents {
applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData];
autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution];
autoModerationRuleCreate: [autoModerationRule: AutoModerationRule];
autoModerationRuleDelete: [autoModerationRule: AutoModerationRule];
autoModerationRuleUpdate: [
oldAutoModerationRule: AutoModerationRule | null,
newAutoModerationRule: AutoModerationRule,
];
...
and two classes, an abstract parent:
export abstract class BaseEvent<K extends keyof ClientEvents> extends Base {
public readonly name : K;
protected constructor (client : Client, name : K, once = false) {
super(client);
this.name = name;
}
public abstract listener (...args : ClientEvents[K]) : Awaitable<void>; // awaitable may or may not be a promise
}
and a child:
export default class MessageCreateEvent extends BaseEvent<'messageCreate'> {
public constructor (client : Client) {
super(client, 'messageCreate'); // not super-convinient that I have to type in the same event name twice but I can't use a type as a value so ¯\_(ツ)_/¯
}
public listener (message) : void { // HERE is the issue !!!
console.log(this.client.user?.id);
}
}
So why doesn't my editor show the typings for listener method arguments in the child class (where I typed !!!)?