mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 14:04:20 -05:00
Show token hints for missing closing braces (#36317)
* Add error for missing brace in object literal * Add new baseline test * Update all affected tests
This commit is contained in:
@@ -5110,13 +5110,22 @@ namespace ts {
|
||||
|
||||
function parseObjectLiteralExpression(): ObjectLiteralExpression {
|
||||
const node = <ObjectLiteralExpression>createNode(SyntaxKind.ObjectLiteralExpression);
|
||||
const openBracePosition = scanner.getTokenPos();
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
node.multiLine = true;
|
||||
}
|
||||
|
||||
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
|
||||
const lastError = lastOrUndefined(parseDiagnostics);
|
||||
if (lastError && lastError.code === Diagnostics._0_expected.code) {
|
||||
addRelatedInfo(
|
||||
lastError,
|
||||
createFileDiagnostic(sourceFile, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
|
||||
);
|
||||
}
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user