Skip to content

Commit

Permalink
Handle constructor on base class
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Jan 12, 2025
1 parent 815721e commit 3b03351
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 602 deletions.
10 changes: 8 additions & 2 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3693,11 +3693,17 @@ export class Resolver extends DiagnosticEmitter {
// Resolve type arguments if generic
if (prototype.is(CommonFlags.Generic)) {

// find the constructor prototype, which may be on a base class
let constructorPrototype: FunctionPrototype | null = null;
for (let p: ClassPrototype | null = prototype; p && !constructorPrototype; p = p.basePrototype) {
constructorPrototype = p.constructorPrototype;
}

// if no type arguments are provided, try to infer them from the constructor call
if (!typeArgumentNodes && prototype.constructorPrototype && flow && ctxTypes.size == 0) {
if (!typeArgumentNodes && constructorPrototype && flow && ctxTypes.size == 0) {
resolvedTypeArguments = this.inferGenericTypeArguments(
reportNode as NewExpression,
prototype.constructorPrototype!,
constructorPrototype,
prototype.typeParameterNodes,
flow,
);
Expand Down
Loading

0 comments on commit 3b03351

Please sign in to comment.