Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use BindableStaticNameExpression not BindableStaticAccessExpression
This type does allow identifiers, but those are ruled out earlier, so I added
an assert for that case.
  • Loading branch information
sandersn committed Apr 30, 2020
commit add6bbcfce5f2b317bcb8cbb82852012f4e6acff
8 changes: 3 additions & 5 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2983,18 +2983,16 @@ namespace ts {
addLateBoundAssignmentDeclarationToSymbol(node, sym);
}
else {
if (!isBindableStaticAccessExpression(node.left)) {
return Debug.fail(`Invalid cast. The supplied value ${getTextOfNode(node.left)} was not a BindableStaticAccessExpression.`);
}
bindStaticPropertyAssignment(node.left as BindableStaticAccessExpression);
bindStaticPropertyAssignment(cast(node.left, isBindableStaticNameExpression));
}
}

/**
* For nodes like `x.y = z`, declare a member 'y' on 'x' if x is a function (or IIFE) or class or {}, or not declared.
* Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y;
*/
function bindStaticPropertyAssignment(node: BindableStaticAccessExpression) {
function bindStaticPropertyAssignment(node: BindableStaticNameExpression) {
Debug.assert(!isIdentifier(node));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Debug.assert(!isIdentifier(node));
Debug.assertNotNode(node, isIdentifier);

node.expression.parent = node;
bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
}
Expand Down