mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00: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:
co-authored by
Daniel Rosenwasser
Nathan Shively-Sanders
parent
76a2ae3d69
commit
62f3ccd9c0
@@ -3308,6 +3308,10 @@
|
||||
"category": "Error",
|
||||
"code": 2808
|
||||
},
|
||||
"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.": {
|
||||
"category": "Error",
|
||||
"code": 2809
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -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