Added logic to check for EOF when creating a missing node.

This commit is contained in:
Armando Aguirre
2017-08-31 14:05:41 -07:00
parent c7b4ed3a91
commit c2168cb94a
6 changed files with 30 additions and 15 deletions

View File

@@ -1208,7 +1208,10 @@ namespace ts {
return finishNode(node);
}
return createMissingNode<Identifier>(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics.Identifier_expected);
// Only for end of file because the error gets reported incorrectly on embedded script tags.
const reportAtCurrentPosition = token() === SyntaxKind.EndOfFileToken;
return createMissingNode<Identifier>(SyntaxKind.Identifier, reportAtCurrentPosition, diagnosticMessage || Diagnostics.Identifier_expected);
}
function parseIdentifier(diagnosticMessage?: DiagnosticMessage): Identifier {

View File

@@ -1,14 +1,14 @@
tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'.
tests/cases/compiler/conflictMarkerTrivia4.ts(1,16): error TS1109: Expression expected.
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'.
!!! error TS1109: Expression expected.
<<<<<<< HEAD
~~~~~~~
!!! error TS1185: Merge conflict marker encountered.
!!! error TS1109: Expression expected.
!!! error TS1185: Merge conflict marker encountered.

View File

@@ -1,5 +1,5 @@
tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,10): error TS2304: Cannot find name 'window'.
tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Identifier expected.
tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,17): error TS1003: Identifier expected.
==== tests/cases/compiler/incompleteDottedExpressionAtEOF.ts (2 errors) ====
@@ -7,5 +7,5 @@ tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Ide
var p2 = window.
~~~~~~
!!! error TS2304: Cannot find name 'window'.
!!! error TS1003: Identifier expected.

View File

@@ -10,11 +10,13 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(14,45): error TS1005: '}' ex
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,2): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,8): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,13): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,83): error TS1109: Expression expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ':' expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '</' expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '}' expected.
==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (14 errors) ====
==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (16 errors) ====
declare var createElement: any;
class foo {}
@@ -57,10 +59,14 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '</' ex
!!! error TS17008: JSX element 'foo' has no corresponding closing tag.
~~~
!!! error TS17008: JSX element 'foo' has no corresponding closing tag.
!!! error TS1109: Expression expected.
!!! error TS1005: ':' expected.
!!! error TS1005: '</' expected.
!!! error TS1005: '</' expected.
!!! error TS1005: '}' expected.

View File

@@ -1,9 +1,10 @@
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,1): error TS2554: Expected 3 arguments, but got 4.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,24): error TS1109: Expression expected.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,28): error TS1109: Expression expected.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,27): error TS1109: Expression expected.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,28): error TS1005: '}' expected.
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts (3 errors) ====
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts (4 errors) ====
function f(x: TemplateStringsArray, y: string, z: string) {
}
@@ -13,5 +14,7 @@ tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(5,28):
!!! error TS2554: Expected 3 arguments, but got 4.
~
!!! error TS1109: Expression expected.
!!! error TS1109: Expression expected.
!!! error TS1109: Expression expected.
!!! error TS1005: '}' expected.

View File

@@ -1,8 +1,9 @@
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(5,1): error TS2554: Expected 3 arguments, but got 4.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(5,30): error TS1109: Expression expected.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(5,29): error TS1109: Expression expected.
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(5,30): error TS1005: '}' expected.
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts (2 errors) ====
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts (3 errors) ====
function f(x: TemplateStringsArray, y: string, z: string) {
}
@@ -10,5 +11,7 @@ tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(5,30):
f `123qdawdrqw${ 1 }${ 2 }${
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.
!!! error TS1109: Expression expected.
!!! error TS1109: Expression expected.
!!! error TS1005: '}' expected.