diff --git a/packages/controller/src/BaseControllerPlugin.ts b/packages/controller/src/BaseControllerPlugin.ts index e515e82d..8a74db3a 100644 --- a/packages/controller/src/BaseControllerPlugin.ts +++ b/packages/controller/src/BaseControllerPlugin.ts @@ -125,7 +125,7 @@ export class ControllerHooks extends lib.AsyncHookCollection { * * @returns an async iterator of prometheus metric results or undefined. */ - readonly metrics: lib.AsyncHook<[], AsyncIterable>; + readonly metrics: lib.AsyncHook<[], AsyncIterable | void>; /** * Called when the controller is shutting down diff --git a/packages/host/src/BaseHostPlugin.ts b/packages/host/src/BaseHostPlugin.ts index 06afe419..32114453 100644 --- a/packages/host/src/BaseHostPlugin.ts +++ b/packages/host/src/BaseHostPlugin.ts @@ -46,7 +46,7 @@ export class HostHooks extends lib.AsyncHookCollection { * * @returns an async iterator of prometheus metric results or undefined. */ - readonly metrics: lib.AsyncHook<[], AsyncIterable>; + readonly metrics: lib.AsyncHook<[], AsyncIterable | void>; /** * Called when the host is shutting down diff --git a/packages/host/src/BaseInstancePlugin.ts b/packages/host/src/BaseInstancePlugin.ts index ac88662e..457c4bbe 100644 --- a/packages/host/src/BaseInstancePlugin.ts +++ b/packages/host/src/BaseInstancePlugin.ts @@ -52,7 +52,7 @@ export class InstanceHooks extends lib.AsyncHookCollection { * * @returns an async iterator of prometheus metric results or undefined. */ - readonly metrics: lib.AsyncHook<[], AsyncIterable>; + readonly metrics: lib.AsyncHook<[], AsyncIterable | void>; /** * Called after the Factorio server is started diff --git a/packages/lib/src/AsyncHook.ts b/packages/lib/src/AsyncHook.ts index a0b8274c..04038da0 100644 --- a/packages/lib/src/AsyncHook.ts +++ b/packages/lib/src/AsyncHook.ts @@ -111,7 +111,7 @@ export class AsyncHook< * * Returns all successful results. */ - async collect(...args: Args): Promise { + async collect(...args: Args): Promise, void>[]> { const results = await Promise.all( [...this._handlers.entries()].map( ([name, handler]) => this._invokeHandler(name, handler, args) @@ -119,7 +119,7 @@ export class AsyncHook< ); return results.filter( - (result): result is Awaited => result !== undefined + (result): result is Exclude, void> => result !== undefined ); }