diff --git a/src/api-test.ts b/src/api-test.ts index b92a7cf..53e0927 100644 --- a/src/api-test.ts +++ b/src/api-test.ts @@ -6,6 +6,17 @@ declare const assertType: (result: [R] extends U ? R : never) => voi function testResolve() { + function testAbstractClass() { + abstract class A { + a = 1; + } + + const a = resolve(A); + if (a.a === 2) { + + } + } + function testResolveSingle() { class A { a = 1 } class B { b = '2' } diff --git a/src/container.ts b/src/container.ts index 744793c..1f35f19 100644 --- a/src/container.ts +++ b/src/container.ts @@ -608,23 +608,25 @@ export class Container { } export type ResolvedValue = - T extends { new (...args: any[]): infer R } + T extends (new (...args: any[]) => infer R) ? R - : T extends Factory - ? (...args: unknown[]) => R - : T extends Lazy - ? () => R - : T extends NewInstance - ? R - : T extends Optional - ? R | null - : T extends All - ? R[] - : T extends Parent - ? R | null - : T extends [infer T1, ...infer T2] - ? [ResolvedValue, ...ResolvedValue] - : T; + : T extends (abstract new (...args: any[]) => infer R) + ? R + : T extends Factory + ? (...args: unknown[]) => R + : T extends Lazy + ? () => R + : T extends NewInstance + ? R + : T extends Optional + ? R | null + : T extends All + ? R[] + : T extends Parent + ? R | null + : T extends [infer T1, ...infer T2] + ? [ResolvedValue, ...ResolvedValue] + : T; /** * Resolve a key, or list of keys based on the current container.