mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Be more lenient with computed property names.
This commit is contained in:
@@ -3753,9 +3753,11 @@ module TypeScript.Parser {
|
||||
// ComputedPropertyName[Yield] :
|
||||
// [AssignmentExpression[In, ?Yield]]
|
||||
|
||||
// Note: we allow any expression inside the computed property name. We'll report any
|
||||
// issues later in the grammar checker if an invalid expression is provided.
|
||||
return new ComputedPropertyNameSyntax(contextFlags,
|
||||
eatToken(SyntaxKind.OpenBracketToken),
|
||||
allowInAnd(parseAssignmentExpressionOrHigher),
|
||||
allowInAnd(parseExpression),
|
||||
eatToken(SyntaxKind.CloseBracketToken));
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,6 +1040,15 @@ module TypeScript {
|
||||
super.visitBreakStatement(node);
|
||||
}
|
||||
|
||||
public visitComputedPropertyName(node: ComputedPropertyNameSyntax): void {
|
||||
if (node.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpressionSyntax>node.expression).operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
this.pushDiagnostic((<BinaryExpressionSyntax>node.expression).operatorToken, DiagnosticCode.comma_expression_cannot_appear_in_a_computed_property_name);
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitComputedPropertyName(node);
|
||||
}
|
||||
|
||||
public visitContinueStatement(node: ContinueStatementSyntax): void {
|
||||
if (this.checkForStatementInAmbientContxt(node) ||
|
||||
this.checkContinueStatementTarget(node)) {
|
||||
|
||||
Reference in New Issue
Block a user