Commit 6d16aba7 authored by nanahira's avatar nanahira

fix

parent e7d1fe86
...@@ -225,8 +225,20 @@ export class AppContextCore<Cur = Empty, Req = Empty> { ...@@ -225,8 +225,20 @@ export class AppContextCore<Cur = Empty, Req = Empty> {
return inst as any; return inst as any;
} }
async getAsync<R>(cls: AppServiceClass<Cur, Req, any, R>): Promise<R> { async getAsync<R>(
const key = cls as unknown as AnyClass; cls:
| AppServiceClass<Cur, Req, any, R>
| (() => AppServiceClass<Cur, Req, any, R>),
): Promise<R> {
let key = cls as unknown as AnyClass;
if (
!this.registry.has(key) &&
typeof cls === 'function' &&
!(cls as any).prototype
) {
key = (cls as () => AppServiceClass<Cur, Req, any, R>)() as AnyClass;
}
if (!this.registry.has(key)) { if (!this.registry.has(key)) {
throw new Error(`Service not provided: ${cls.name}`); throw new Error(`Service not provided: ${cls.name}`);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment