diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 0c4c087e6e..6cac0cb193 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2374,6 +2374,7 @@ namespace ts { tokenValue = tokenValue.slice(0, -1); pos--; } + return getIdentifierToken(); } return token; } diff --git a/tests/baselines/reference/jsxParsingError4(strict=false).js b/tests/baselines/reference/jsxParsingError4(strict=false).js new file mode 100644 index 0000000000..930ef5072a --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=false).js @@ -0,0 +1,20 @@ +//// [a.tsx] +declare const React: any +declare namespace JSX { + interface IntrinsicElements { + [k: string]: any + } +} + +const a = ( + +); + +const b = ( + +); + + +//// [a.js] +var a = (React.createElement("public-foo", null)); +var b = (React.createElement("public", null)); diff --git a/tests/baselines/reference/jsxParsingError4(strict=false).symbols b/tests/baselines/reference/jsxParsingError4(strict=false).symbols new file mode 100644 index 0000000000..b4f35e534f --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=false).symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare const React: any +>React : Symbol(React, Decl(a.tsx, 0, 13)) + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(a.tsx, 0, 24)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 1, 23)) + + [k: string]: any +>k : Symbol(k, Decl(a.tsx, 3, 9)) + } +} + +const a = ( +>a : Symbol(a, Decl(a.tsx, 7, 5)) + + +>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) +>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) + +); + +const b = ( +>b : Symbol(b, Decl(a.tsx, 11, 5)) + + +>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) +>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) + +); + diff --git a/tests/baselines/reference/jsxParsingError4(strict=false).types b/tests/baselines/reference/jsxParsingError4(strict=false).types new file mode 100644 index 0000000000..021360520c --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=false).types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare const React: any +>React : any + +declare namespace JSX { + interface IntrinsicElements { + [k: string]: any +>k : string + } +} + +const a = ( +>a : error +>( ) : error + + +> : error +>public-foo : any +>public-foo : any + +); + +const b = ( +>b : error +>( ) : error + + +> : error +>public : any +>public : any + +); + diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt b/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt new file mode 100644 index 0000000000..aeac8698a0 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=true).errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/jsx/a.tsx(13,4): error TS1212: Identifier expected. 'public' is a reserved word in strict mode. +tests/cases/conformance/jsx/a.tsx(13,13): error TS1212: Identifier expected. 'public' is a reserved word in strict mode. + + +==== tests/cases/conformance/jsx/a.tsx (2 errors) ==== + declare const React: any + declare namespace JSX { + interface IntrinsicElements { + [k: string]: any + } + } + + const a = ( + + ); + + const b = ( + + ~~~~~~ +!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode. + ~~~~~~ +!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode. + ); + \ No newline at end of file diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).js b/tests/baselines/reference/jsxParsingError4(strict=true).js new file mode 100644 index 0000000000..efa0735dc7 --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=true).js @@ -0,0 +1,21 @@ +//// [a.tsx] +declare const React: any +declare namespace JSX { + interface IntrinsicElements { + [k: string]: any + } +} + +const a = ( + +); + +const b = ( + +); + + +//// [a.js] +"use strict"; +var a = (React.createElement("public-foo", null)); +var b = (React.createElement("public", null)); diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).symbols b/tests/baselines/reference/jsxParsingError4(strict=true).symbols new file mode 100644 index 0000000000..b4f35e534f --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=true).symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare const React: any +>React : Symbol(React, Decl(a.tsx, 0, 13)) + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(a.tsx, 0, 24)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 1, 23)) + + [k: string]: any +>k : Symbol(k, Decl(a.tsx, 3, 9)) + } +} + +const a = ( +>a : Symbol(a, Decl(a.tsx, 7, 5)) + + +>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) +>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) + +); + +const b = ( +>b : Symbol(b, Decl(a.tsx, 11, 5)) + + +>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) +>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23)) + +); + diff --git a/tests/baselines/reference/jsxParsingError4(strict=true).types b/tests/baselines/reference/jsxParsingError4(strict=true).types new file mode 100644 index 0000000000..f65d2d679b --- /dev/null +++ b/tests/baselines/reference/jsxParsingError4(strict=true).types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsx/a.tsx === +declare const React: any +>React : any + +declare namespace JSX { + interface IntrinsicElements { + [k: string]: any +>k : string + } +} + +const a = ( +>a : any +>( ) : any + + +> : any +>public-foo : any +>public-foo : any + +); + +const b = ( +>b : any +>( ) : any + + +> : any +>public : any +>public : any + +); + diff --git a/tests/cases/conformance/jsx/jsxParsingError4.tsx b/tests/cases/conformance/jsx/jsxParsingError4.tsx new file mode 100644 index 0000000000..c4db4fe7ab --- /dev/null +++ b/tests/cases/conformance/jsx/jsxParsingError4.tsx @@ -0,0 +1,18 @@ +// @strict: true, false +// @jsx: react +// @filename: a.tsx + +declare const React: any +declare namespace JSX { + interface IntrinsicElements { + [k: string]: any + } +} + +const a = ( + +); + +const b = ( + +);