Skip to content

Commit 7eb4cde

Browse files
sandersntypescript-bot
authored andcommitted
Cherry-pick PR microsoft#38270 into release-3.9
Component commits: 9795fa6 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. d815eff fix lint add6bbc Use BindableStaticNameExpression not BindableStaticAccessExpression This type does allow identifiers, but those are ruled out earlier, so I added an assert for that case.
1 parent a073560 commit 7eb4cde

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/compiler/binder.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -2977,23 +2977,22 @@ 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+
bindStaticPropertyAssignment(cast(node.left, isBindableStaticNameExpression));
29892987
}
29902988
}
29912989

29922990
/**
29932991
* 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.
29942992
* Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y;
29952993
*/
2996-
function bindStaticPropertyAssignment(node: BindableStaticAccessExpression) {
2994+
function bindStaticPropertyAssignment(node: BindableStaticNameExpression) {
2995+
Debug.assert(!isIdentifier(node));
29972996
node.expression.parent = node;
29982997
bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false);
29992998
}

0 commit comments

Comments
 (0)