From 815721ef1a0ecd3f3949baee59918d32e6c2430c Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Sat, 11 Jan 2025 22:45:25 -0800 Subject: [PATCH] Fix bootstrap errors --- src/resolver.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/resolver.ts b/src/resolver.ts index 0aa68afbd9..a42fd2522a 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -752,7 +752,7 @@ export class Resolver extends DiagnosticEmitter { } private inferGenericTypeArguments( - node: CallExpression | NewExpression, + node: Expression, prototype: FunctionPrototype, typeParameterNodes: TypeParameterNode[] | null, ctxFlow: Flow, @@ -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 = (node).args; + break; + case NodeKind.New: + argumentNodes = (node).args; + break; + default: + assert(false); + return null; + } + let numArguments = argumentNodes.length; // infer types with generic components while updating contextual types @@ -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, );