Skip to content

Commit 815721e

Browse files
Fix bootstrap errors
1 parent 983c40f commit 815721e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/resolver.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ export class Resolver extends DiagnosticEmitter {
752752
}
753753

754754
private inferGenericTypeArguments(
755-
node: CallExpression | NewExpression,
755+
node: Expression,
756756
prototype: FunctionPrototype,
757757
typeParameterNodes: TypeParameterNode[] | null,
758758
ctxFlow: Flow,
@@ -776,7 +776,20 @@ export class Resolver extends DiagnosticEmitter {
776776

777777
let parameterNodes = prototype.functionTypeNode.parameters;
778778
let numParameters = parameterNodes.length;
779-
let argumentNodes = node.args;
779+
780+
let argumentNodes: Expression[];
781+
switch (node.kind) {
782+
case NodeKind.Call:
783+
argumentNodes = (<CallExpression>node).args;
784+
break;
785+
case NodeKind.New:
786+
argumentNodes = (<NewExpression>node).args;
787+
break;
788+
default:
789+
assert(false);
790+
return null;
791+
}
792+
780793
let numArguments = argumentNodes.length;
781794

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

36833696
// if no type arguments are provided, try to infer them from the constructor call
3684-
if (!typeArgumentNodes && prototype.constructorPrototype && flow) {
3697+
if (!typeArgumentNodes && prototype.constructorPrototype && flow && ctxTypes.size == 0) {
36853698
resolvedTypeArguments = this.inferGenericTypeArguments(
36863699
reportNode as NewExpression,
3687-
prototype.constructorPrototype,
3700+
prototype.constructorPrototype!,
36883701
prototype.typeParameterNodes,
36893702
flow,
36903703
);

0 commit comments

Comments
 (0)