Skip to content

Commit 9795fa6

Browse files
committed
Improve assert message in binder
Looking at the code, I don't think the assert can ever fire, but it clearly does, or did in the past. This will make it easier for people to create a repro.
1 parent 70b9b08 commit 9795fa6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/compiler/binder.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -2977,15 +2977,15 @@ namespace ts {
29772977
// util.property = function ...
29782978
bindExportsPropertyAssignment(node as BindableStaticPropertyAssignmentExpression);
29792979
}
2980+
else if (hasDynamicName(node)) {
2981+
bindAnonymousDeclaration(node, SymbolFlags.Property | SymbolFlags.Assignment, InternalSymbolName.Computed);
2982+
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
2983+
addLateBoundAssignmentDeclarationToSymbol(node, sym);
2984+
}
29802985
else {
2981-
if (hasDynamicName(node)) {
2982-
bindAnonymousDeclaration(node, SymbolFlags.Property | SymbolFlags.Assignment, InternalSymbolName.Computed);
2983-
const sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false);
2984-
addLateBoundAssignmentDeclarationToSymbol(node, sym);
2985-
}
2986-
else {
2987-
bindStaticPropertyAssignment(cast(node.left, isBindableStaticAccessExpression));
2988-
}
2986+
if (!isBindableStaticAccessExpression(node.left))
2987+
return Debug.fail(`Invalid cast. The supplied value ${getTextOfNode(node.left)} was not a BindableStaticAccessExpression.`);
2988+
bindStaticPropertyAssignment(node.left as BindableStaticAccessExpression);
29892989
}
29902990
}
29912991

0 commit comments

Comments
 (0)