refactor: switching to when statements and type predicates

This commit is contained in:
Jacob Nguyen
2022-05-16 02:40:17 -05:00
parent bcbfd28788
commit d9db485202
4 changed files with 40 additions and 18 deletions

View File

@@ -50,6 +50,9 @@ export type EventPlugin<T extends CommandType> = {
{
execute: (event: Parameters<ModuleDefs[T]['execute']>, controller: Controller) => Awaitable<Result<void, void>>;
}>;
export type EventPluginType = {
[K in CommandType] : EventPlugin<K>
}
export function plugins(...plug: CommandPlugin[]): CommandPlugin[];
export function plugins<T extends CommandType>(...plug: EventPlugin<T>[]): EventPlugin<T>[];
@@ -58,6 +61,6 @@ export function plugins<T extends CommandType>(...plug: CommandPlugin[] | EventP
return plug;
}
export function sernModule(mod: Module): Module {
export function sernModule<T extends CommandType>(mod: ModuleDefs[T]): Module {
return mod;
}