diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e4262458d30..a6e1c03db25 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3639,7 +3639,7 @@ namespace ts { parseExpected(SyntaxKind.OpenBraceToken); if (token !== SyntaxKind.CloseBraceToken) { - node.expression = parseExpression(); + node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { parseExpected(SyntaxKind.CloseBraceToken); diff --git a/tests/baselines/reference/jsxParsingError1.errors.txt b/tests/baselines/reference/jsxParsingError1.errors.txt new file mode 100644 index 00000000000..e769947dfa6 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError1.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/jsx/file.tsx(12,36): error TS1005: '}' expected. +tests/cases/conformance/jsx/file.tsx(12,44): error TS1003: Identifier expected. +tests/cases/conformance/jsx/file.tsx(12,46): error TS1161: Unterminated regular expression literal. + + +==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } + } + + // This should be a parse error + const class1 = "foo"; + const class2 = "bar"; + const elem =
; + ~ +!!! error TS1005: '}' expected. + ~ +!!! error TS1003: Identifier expected. + +!!! error TS1161: Unterminated regular expression literal. + \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError1.js b/tests/baselines/reference/jsxParsingError1.js new file mode 100644 index 00000000000..14b60afdde8 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError1.js @@ -0,0 +1,21 @@ +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// This should be a parse error +const class1 = "foo"; +const class2 = "bar"; +const elem =
; + + +//// [file.jsx] +// This should be a parse error +var class1 = "foo"; +var class2 = "bar"; +var elem =
; +/>;; diff --git a/tests/cases/conformance/jsx/jsxParsingError1.tsx b/tests/cases/conformance/jsx/jsxParsingError1.tsx new file mode 100644 index 00000000000..2668f04e885 --- /dev/null +++ b/tests/cases/conformance/jsx/jsxParsingError1.tsx @@ -0,0 +1,14 @@ +//@jsx: preserve + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +// This should be a parse error +const class1 = "foo"; +const class2 = "bar"; +const elem =
;