diff --git a/packages/runtime/src/interfaces/iocModule.ts b/packages/runtime/src/interfaces/iocModule.ts index b6d84c3c3..26bcdccc3 100644 --- a/packages/runtime/src/interfaces/iocModule.ts +++ b/packages/runtime/src/interfaces/iocModule.ts @@ -1,7 +1,19 @@ -export interface IocContainer { - get(controller: { prototype: T }): T; +export type Newable< + T = unknown, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + TArgs extends unknown[] = any[], +> = new (...args: TArgs) => T; + +export type ServiceIdentifier = + | string + | symbol + | Newable + // eslint-disable-next-line @typescript-eslint/ban-types + | Function; - get(controller: { prototype: T }): Promise; +export interface IocContainer { + get(controller: ServiceIdentifier): T; + get(controller: ServiceIdentifier): Promise; } // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/tests/fixtures/inversify-async/ioc.ts b/tests/fixtures/inversify-async/ioc.ts index 5d44e2f62..b063cde3d 100644 --- a/tests/fixtures/inversify-async/ioc.ts +++ b/tests/fixtures/inversify-async/ioc.ts @@ -1,4 +1,4 @@ -import { Container } from 'inversify'; +import { Container, interfaces } from 'inversify'; import { AsyncController } from './asyncController'; import { AsyncService } from './asyncService'; import { AsyncErrorController } from './asyncErrorController'; @@ -15,7 +15,7 @@ container.bind('error').toFactory(() => { container.bind(AsyncErrorController).to(AsyncErrorController).inSingletonScope(); const iocContainer = { - async get(controller: { prototype: T }): Promise { + async get(controller: interfaces.ServiceIdentifier): Promise { return container.get(controller); }, };