From 830a1b96e4fc579906846a1564f0a172f8f73c6f Mon Sep 17 00:00:00 2001 From: Veys Aliyev <40066034+MDReal32@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:03:06 +0400 Subject: [PATCH] Add support for return types on callHook/callHookParallel any is evil ((( --- src/hookable.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hookable.ts b/src/hookable.ts index 6aea45af..44bb722e 100644 --- a/src/hookable.ts +++ b/src/hookable.ts @@ -21,6 +21,7 @@ type InferSpyEvent> = { context: Record; }; }[keyof HT]; +type Promisify = T extends Promise ? Promise : Promise export class Hookable< HooksT extends Record = Record, @@ -189,7 +190,7 @@ export class Hookable< callHook( name: NameT, ...arguments_: Parameters> - ): Promise { + ): Promisify>> { arguments_.unshift(name); return this.callHookWith(serialTaskCaller, name, ...arguments_); } @@ -197,7 +198,7 @@ export class Hookable< callHookParallel( name: NameT, ...arguments_: Parameters> - ): Promise { + ): Promisify>> { arguments_.unshift(name); return this.callHookWith(parallelTaskCaller, name, ...arguments_); }