mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-11 06:02:53 -05:00
Merge pull request #14132 from Microsoft/master-fix12952
[Master] Fix 12952 : throw exception when parsing conflict marker in JSX
This commit is contained in:
@@ -3863,6 +3863,9 @@ namespace ts {
|
||||
parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTagName));
|
||||
break;
|
||||
}
|
||||
else if (token() === SyntaxKind.ConflictMarkerTrivia) {
|
||||
break;
|
||||
}
|
||||
result.push(parseJsxChild());
|
||||
}
|
||||
|
||||
|
||||
@@ -1716,7 +1716,14 @@ namespace ts {
|
||||
while (pos < end) {
|
||||
pos++;
|
||||
char = text.charCodeAt(pos);
|
||||
if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) {
|
||||
if (char === CharacterCodes.openBrace) {
|
||||
break;
|
||||
}
|
||||
if (char === CharacterCodes.lessThan) {
|
||||
if (isConflictMarkerTrivia(text, pos)) {
|
||||
pos = scanConflictMarkerTrivia(text, pos, error);
|
||||
return token = SyntaxKind.ConflictMarkerTrivia;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
15
tests/baselines/reference/conflictMarkerTrivia3.errors.txt
Normal file
15
tests/baselines/reference/conflictMarkerTrivia3.errors.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/conflictMarkerTrivia3.tsx(1,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
|
||||
tests/cases/compiler/conflictMarkerTrivia3.tsx(1,16): error TS1005: '</' expected.
|
||||
tests/cases/compiler/conflictMarkerTrivia3.tsx(2,1): error TS1185: Merge conflict marker encountered.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conflictMarkerTrivia3.tsx (3 errors) ====
|
||||
const x = <div>
|
||||
~~~~~
|
||||
!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
|
||||
|
||||
<<<<<<< HEAD
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1005: '</' expected.
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
6
tests/baselines/reference/conflictMarkerTrivia3.js
Normal file
6
tests/baselines/reference/conflictMarkerTrivia3.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [conflictMarkerTrivia3.tsx]
|
||||
const x = <div>
|
||||
<<<<<<< HEAD
|
||||
|
||||
//// [conflictMarkerTrivia3.js]
|
||||
var x = <div></>;
|
||||
14
tests/baselines/reference/conflictMarkerTrivia4.errors.txt
Normal file
14
tests/baselines/reference/conflictMarkerTrivia4.errors.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'.
|
||||
tests/cases/compiler/conflictMarkerTrivia4.ts(2,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerTrivia4.ts(2,13): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conflictMarkerTrivia4.ts (3 errors) ====
|
||||
const x = <div>
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'div'.
|
||||
<<<<<<< HEAD
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
6
tests/baselines/reference/conflictMarkerTrivia4.js
Normal file
6
tests/baselines/reference/conflictMarkerTrivia4.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [conflictMarkerTrivia4.ts]
|
||||
const x = <div>
|
||||
<<<<<<< HEAD
|
||||
|
||||
//// [conflictMarkerTrivia4.js]
|
||||
var x = ;
|
||||
2
tests/cases/compiler/conflictMarkerTrivia3.tsx
Normal file
2
tests/cases/compiler/conflictMarkerTrivia3.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
const x = <div>
|
||||
<<<<<<< HEAD
|
||||
2
tests/cases/compiler/conflictMarkerTrivia4.ts
Normal file
2
tests/cases/compiler/conflictMarkerTrivia4.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
const x = <div>
|
||||
<<<<<<< HEAD
|
||||
Reference in New Issue
Block a user