Skip to content

Commit 2856aab

Browse files
committed
Parse stray identifier-ish as JSXText instead of trivia
1 parent feaef9c commit 2856aab

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,8 +4439,9 @@ namespace ts {
44394439
parseExpected(SyntaxKind.CloseBraceToken);
44404440
}
44414441
else {
4442-
parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*shouldAdvance*/ false);
4443-
scanJsxText();
4442+
if (parseExpected(SyntaxKind.CloseBraceToken, /*message*/ undefined, /*shouldAdvance*/ false)) {
4443+
scanJsxText();
4444+
}
44444445
}
44454446

44464447
return finishNode(node);

src/harness/fourslash.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,13 @@ namespace FourSlash {
582582
});
583583
}
584584

585-
public verifyErrorExistsAtRange(range: Range, code: number) {
585+
public verifyErrorExistsAtRange(range: Range, code: number, expectedMessage?: string) {
586586
const span = ts.createTextSpanFromRange(range);
587587
const hasMatchingError = ts.some(
588588
this.getDiagnostics(range.fileName),
589-
({ code, start, length }) =>
589+
({ code, messageText, start, length }) =>
590590
code === code &&
591+
(!expectedMessage || expectedMessage === messageText) &&
591592
ts.isNumber(start) && ts.isNumber(length) &&
592593
ts.textSpansEqual(span, { start, length }));
593594

@@ -3982,8 +3983,8 @@ namespace FourSlashInterface {
39823983
this.state.verifyNoErrors();
39833984
}
39843985

3985-
public errorExistsAtRange(range: FourSlash.Range, code: number) {
3986-
this.state.verifyErrorExistsAtRange(range, code);
3986+
public errorExistsAtRange(range: FourSlash.Range, code: number, message?: string) {
3987+
this.state.verifyErrorExistsAtRange(range, code, message);
39873988
}
39883989

39893990
public numberOfErrorsInCurrentFile(expected: number) {

tests/cases/fourslash/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ declare namespace FourSlashInterface {
238238
signatureHelp(...options: VerifySignatureHelpOptions[], ): void;
239239
// Checks that there are no compile errors.
240240
noErrors(): void;
241-
errorExistsAtRange(range: Range, code: number): void;
241+
errorExistsAtRange(range: Range, code: number, message?: string): void;
242242
numberOfErrorsInCurrentFile(expected: number): void;
243243
baselineCurrentFileBreakpointLocations(): void;
244244
baselineCurrentFileNameOrDottedNameSpans(): void;

tests/cases/fourslash/jsxExpressionFollowedByIdentifier.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
//@Filename: jsxExpressionFollowedByIdentifier.tsx
44
////declare var React: any;
5-
////declare var x: string;
65
////const a = <div>{<div />[|x|]}</div>
76
////const b = <div x={<div />[|x|]} />
87

9-
const range = test.ranges()[0];
10-
verify.getSyntacticDiagnostics([{
11-
code: 1005,
12-
message: "'}' expected.",
13-
range,
14-
}]);
15-
verify.quickInfoAt(range, 'var x: string');
8+
test.ranges().forEach(range => {
9+
verify.errorExistsAtRange(range, 1005, "'}' expected.");
10+
// This is just to ensure getting quick info doesn’t crash
11+
verify.not.quickInfoExists();
12+
});

0 commit comments

Comments
 (0)