mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
isDynamicName skips parentheses for element access
Neither `x[0]` nor `x[(0)]` should be dynamic names. Previously, the latter was because `isDynamicName` didn't skip parentheses. Since the binder treats dynamic names in property assignments as assignment declarations, this incorrectly tried to create a binding for expressions like `x[(0)] = 1`. This caused an assert because `x[(0)]` would not take the dynamic name code path during binding (`hasDynamicName` returned false), but the normal code path for static names.
This commit is contained in:
1 parent
ffa35d3272
commit
a64166de14
4 files changed
+31
-1
No files matched your search
@@ -3061,7 +3061,7 @@ namespace ts {
|
||||
if (!(name.kind === SyntaxKind.ComputedPropertyName || name.kind === SyntaxKind.ElementAccessExpression)) {
|
||||
return false;
|
||||
}
|
||||
const expr = isElementAccessExpression(name) ? name.argumentExpression : name.expression;
|
||||
const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
|
||||
return !isStringOrNumericLiteralLike(expr) &&
|
||||
!isSignedNumericLiteral(expr) &&
|
||||
!isWellKnownSymbolSyntactically(expr);
|
||||
|
||||
Reference in new issue
Block a user