mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Error if assignment after block (#41115)
* Error if assignment after block * Update src/compiler/diagnosticMessages.json Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> * Fix diags * Error after block Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
@@ -2109,8 +2109,7 @@ namespace ts {
|
||||
|
||||
while (!isListTerminator(kind)) {
|
||||
if (isListElement(kind, /*inErrorRecovery*/ false)) {
|
||||
const element = parseListElement(kind, parseElement);
|
||||
list.push(element);
|
||||
list.push(parseListElement(kind, parseElement));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -5602,7 +5601,13 @@ namespace ts {
|
||||
const multiLine = scanner.hasPrecedingLineBreak();
|
||||
const statements = parseList(ParsingContext.BlockStatements, parseStatement);
|
||||
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
|
||||
return finishNode(factory.createBlock(statements, multiLine), pos);
|
||||
const result = finishNode(factory.createBlock(statements, multiLine), pos);
|
||||
if (token() === SyntaxKind.EqualsToken) {
|
||||
parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
|
||||
nextToken();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
const statements = createMissingList<Statement>();
|
||||
|
||||
Reference in New Issue
Block a user