Skip to content

Commit

Permalink
Fix bootstrap errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Jan 12, 2025
1 parent 983c40f commit 815721e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ export class Resolver extends DiagnosticEmitter {
}

private inferGenericTypeArguments(
node: CallExpression | NewExpression,
node: Expression,
prototype: FunctionPrototype,
typeParameterNodes: TypeParameterNode[] | null,
ctxFlow: Flow,
Expand All @@ -776,7 +776,20 @@ export class Resolver extends DiagnosticEmitter {

let parameterNodes = prototype.functionTypeNode.parameters;
let numParameters = parameterNodes.length;
let argumentNodes = node.args;

let argumentNodes: Expression[];
switch (node.kind) {
case NodeKind.Call:
argumentNodes = (<CallExpression>node).args;
break;
case NodeKind.New:
argumentNodes = (<NewExpression>node).args;
break;
default:
assert(false);
return null;
}

let numArguments = argumentNodes.length;

// infer types with generic components while updating contextual types
Expand Down Expand Up @@ -3681,10 +3694,10 @@ export class Resolver extends DiagnosticEmitter {
if (prototype.is(CommonFlags.Generic)) {

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

0 comments on commit 815721e

Please sign in to comment.