Skip to content

Commit 3b03351

Browse files
Handle constructor on base class
1 parent 815721e commit 3b03351

File tree

4 files changed

+235
-602
lines changed

4 files changed

+235
-602
lines changed

src/resolver.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,11 +3693,17 @@ export class Resolver extends DiagnosticEmitter {
36933693
// Resolve type arguments if generic
36943694
if (prototype.is(CommonFlags.Generic)) {
36953695

3696+
// find the constructor prototype, which may be on a base class
3697+
let constructorPrototype: FunctionPrototype | null = null;
3698+
for (let p: ClassPrototype | null = prototype; p && !constructorPrototype; p = p.basePrototype) {
3699+
constructorPrototype = p.constructorPrototype;
3700+
}
3701+
36963702
// if no type arguments are provided, try to infer them from the constructor call
3697-
if (!typeArgumentNodes && prototype.constructorPrototype && flow && ctxTypes.size == 0) {
3703+
if (!typeArgumentNodes && constructorPrototype && flow && ctxTypes.size == 0) {
36983704
resolvedTypeArguments = this.inferGenericTypeArguments(
36993705
reportNode as NewExpression,
3700-
prototype.constructorPrototype!,
3706+
constructorPrototype,
37013707
prototype.typeParameterNodes,
37023708
flow,
37033709
);

0 commit comments

Comments
 (0)