diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 78df166633c..f085c3ffc06 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -932,7 +932,7 @@ namespace ts { return value; } - function scanString(allowEscapes = true): string { + function scanString(jsxAttributeString = false): string { const quote = text.charCodeAt(pos); pos++; let result = ""; @@ -950,13 +950,13 @@ namespace ts { pos++; break; } - if (ch === CharacterCodes.backslash && allowEscapes) { + if (ch === CharacterCodes.backslash && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; continue; } - if (isLineBreak(ch)) { + if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_string_literal); @@ -1811,7 +1811,7 @@ namespace ts { switch (text.charCodeAt(pos)) { case CharacterCodes.doubleQuote: case CharacterCodes.singleQuote: - tokenValue = scanString(/*allowEscapes*/ false); + tokenValue = scanString(/*jsxAttributeString*/ true); return token = SyntaxKind.StringLiteral; default: // If this scans anything other than `{`, it's a parse error. diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index ab44db8ef4b..35eaae2a5cf 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -6,6 +6,7 @@ namespace ts { export function transformJsx(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); + let currentSourceFile: SourceFile; return transformSourceFile; @@ -19,6 +20,7 @@ namespace ts { return node; } + currentSourceFile = node; const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -167,8 +169,11 @@ namespace ts { return createTrue(); } else if (node.kind === SyntaxKind.StringLiteral) { - const decoded = tryDecodeEntities((node).text); - return decoded ? setTextRange(createLiteral(decoded), node) : node; + // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which + // Need to be escaped to be handled correctly in a normal string + const literal = createLiteral(tryDecodeEntities((node).text) || (node).text); + literal.singleQuote = (node as StringLiteral).singleQuote !== undefined ? (node as StringLiteral).singleQuote : !isStringDoubleQuoted(node as StringLiteral, currentSourceFile); + return setTextRange(literal, node); } else if (node.kind === SyntaxKind.JsxExpression) { if (node.expression === undefined) { diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt index 8af8f5033ba..53541851b4a 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.errors.txt @@ -1,76 +1,92 @@ -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,1): error TS1128: Declaration or statement expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,3): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(3,4): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(4,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,1): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,2): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,3): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,6): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(5,7): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,1): error TS2695: Left side of comma operator is unused and has no side effects. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,6): error TS2304: Cannot find name 'd'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,9): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(6,10): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(7,1): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(8,4): error TS17002: Expected corresponding JSX closing tag for 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(9,13): error TS1002: Unterminated string literal. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,1): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,6): error TS17002: Expected corresponding JSX closing tag for 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(10,10): error TS2657: JSX expressions must have one parent element. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,5): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,11): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,12): error TS2304: Cannot find name 'b'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(11,16): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,5): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,10): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,13): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,14): error TS2304: Cannot find name 'c'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(12,16): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(13,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,1): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,2): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,5): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,7): error TS1128: Declaration or statement expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,8): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(14,10): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,2): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,4): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,7): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(15,9): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,4): error TS2304: Cannot find name 'foo'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,9): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,11): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,13): error TS2304: Cannot find name 'foo'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(16,18): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,3): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,11): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,13): error TS2304: Cannot find name 'a'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(17,22): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(18,2): error TS17008: JSX element 'a' has no corresponding closing tag. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(19,2): error TS17008: JSX element 'a' has no corresponding closing tag. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(22,10): error TS1005: '}' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(23,20): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(24,15): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS1005: '...' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(25,7): error TS2304: Cannot find name 'props'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(27,17): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,10): error TS2304: Cannot find name 'props'. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(28,28): error TS1005: '>' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,2): error TS17008: JSX element 'a' has no corresponding closing tag. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(32,6): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,2): error TS17008: JSX element 'a' has no corresponding closing tag. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,6): error TS1005: '{' expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(33,7): error TS1109: Expression expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,4): error TS1003: Identifier expected. -tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: '' expected. +tests/cases/conformance/jsx/10.tsx(1,14): error TS2304: Cannot find name 'c'. +tests/cases/conformance/jsx/10.tsx(1,16): error TS1109: Expression expected. +tests/cases/conformance/jsx/11.tsx(1,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/11.tsx(1,8): error TS17002: Expected corresponding JSX closing tag for 'a.b.c'. +tests/cases/conformance/jsx/12.tsx(1,1): error TS1109: Expression expected. +tests/cases/conformance/jsx/12.tsx(1,2): error TS1109: Expression expected. +tests/cases/conformance/jsx/12.tsx(1,5): error TS1109: Expression expected. +tests/cases/conformance/jsx/12.tsx(1,7): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/12.tsx(1,8): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/12.tsx(1,10): error TS1109: Expression expected. +tests/cases/conformance/jsx/13.tsx(1,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/13.tsx(1,4): error TS1003: Identifier expected. +tests/cases/conformance/jsx/13.tsx(1,7): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/13.tsx(1,9): error TS1003: Identifier expected. +tests/cases/conformance/jsx/14.tsx(1,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/14.tsx(1,4): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/14.tsx(1,9): error TS1109: Expression expected. +tests/cases/conformance/jsx/14.tsx(1,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/14.tsx(1,13): error TS2304: Cannot find name 'foo'. +tests/cases/conformance/jsx/14.tsx(1,18): error TS1109: Expression expected. +tests/cases/conformance/jsx/15.tsx(1,3): error TS1003: Identifier expected. +tests/cases/conformance/jsx/15.tsx(1,11): error TS1109: Expression expected. +tests/cases/conformance/jsx/15.tsx(1,13): error TS2304: Cannot find name 'a'. +tests/cases/conformance/jsx/15.tsx(1,22): error TS1109: Expression expected. +tests/cases/conformance/jsx/16.tsx(1,2): error TS17008: JSX element 'a' has no corresponding closing tag. +tests/cases/conformance/jsx/16.tsx(1,10): error TS1005: '' expected. +tests/cases/conformance/jsx/24.tsx(1,18): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/24.tsx(1,21): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/24.tsx(1,27): error TS1109: Expression expected. +tests/cases/conformance/jsx/24.tsx(1,28): error TS1109: Expression expected. +tests/cases/conformance/jsx/25.tsx(1,10): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/25.tsx(1,28): error TS1005: '>' expected. +tests/cases/conformance/jsx/25.tsx(1,29): error TS1128: Declaration or statement expected. +tests/cases/conformance/jsx/25.tsx(1,32): error TS2304: Cannot find name 'props'. +tests/cases/conformance/jsx/25.tsx(1,38): error TS1109: Expression expected. +tests/cases/conformance/jsx/25.tsx(1,39): error TS1109: Expression expected. +tests/cases/conformance/jsx/28.tsx(1,2): error TS17008: JSX element 'a' has no corresponding closing tag. +tests/cases/conformance/jsx/28.tsx(1,6): error TS1005: '{' expected. +tests/cases/conformance/jsx/28.tsx(2,1): error TS1005: '' expected. +tests/cases/conformance/jsx/9.tsx(1,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/jsx/9.tsx(1,16): error TS1109: Expression expected. -==== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx (70 errors) ==== +==== tests/cases/conformance/jsx/1.tsx (3 errors) ==== declare var React: any; ; @@ -80,9 +96,11 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: !!! error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. +==== tests/cases/conformance/jsx/2.tsx (1 errors) ==== ; ~ !!! error TS1003: Identifier expected. +==== tests/cases/conformance/jsx/3.tsx (5 errors) ==== <:a />; ~ !!! error TS1109: Expression expected. @@ -94,9 +112,8 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: !!! error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. +==== tests/cases/conformance/jsx/4.tsx (5 errors) ==== ; - ~~~~~~~~~~ -!!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS1005: '{' expected. ~ @@ -105,22 +122,29 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: !!! error TS1109: Expression expected. ~ !!! error TS1109: Expression expected. + +!!! error TS1005: '/' expected. +==== tests/cases/conformance/jsx/5.tsx (2 errors) ==== ; - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS17008: JSX element 'a' has no corresponding closing tag. + +!!! error TS1005: '; ~~~~ !!! error TS17002: Expected corresponding JSX closing tag for 'a'. +==== tests/cases/conformance/jsx/7.tsx (1 errors) ==== ; ~ !!! error TS1005: '}' expected. +==== tests/cases/conformance/jsx/21.tsx (1 errors) ==== ; ~ !!! error TS1003: Identifier expected. +==== tests/cases/conformance/jsx/22.tsx (2 errors) ====
; ~~~~~ !!! error TS1003: Identifier expected. + ~ +!!! error TS1109: Expression expected. +==== tests/cases/conformance/jsx/23.tsx (2 errors) ====
; ~~~~~ !!! error TS1005: '...' expected. ~~~~~ !!! error TS2304: Cannot find name 'props'. +==== tests/cases/conformance/jsx/24.tsx (5 errors) ====
stuff
; ~ !!! error TS1005: '>' expected. + ~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + +==== tests/cases/conformance/jsx/25.tsx (6 errors) ====
stuff
; ~~~~~ !!! error TS2304: Cannot find name 'props'. ~ !!! error TS1005: '>' expected. + ~~~ +!!! error TS1128: Declaration or statement expected. + ~~~~~ +!!! error TS2304: Cannot find name 'props'. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1109: Expression expected. + +==== tests/cases/conformance/jsx/26.tsx (0 errors) ====
>; + +==== tests/cases/conformance/jsx/27.tsx (0 errors) ==== >; + +==== tests/cases/conformance/jsx/28.tsx (3 errors) ==== ; ~ !!! error TS17008: JSX element 'a' has no corresponding closing tag. ~ !!! error TS1005: '{' expected. + + +!!! error TS1005: '; ~ !!! error TS17008: JSX element 'a' has no corresponding closing tag. @@ -240,9 +321,13 @@ tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx(35,21): error TS1005: !!! error TS1005: '{' expected. ~ !!! error TS1109: Expression expected. + + +!!! error TS1005: '}; + +==== tests/cases/conformance/jsx/31.tsx (1 errors) ==== ; ~~~ -!!! error TS1003: Identifier expected. - -!!! error TS1005: '; -; -<:a />; -; -; -; -; -; -
; +; +//// [2.tsx] +; +//// [3.tsx] +<:a />; +//// [4.tsx] +; +//// [5.tsx] +; +//// [6.tsx] +; +//// [7.tsx] +; +//// [21.tsx] +; +//// [22.tsx] +
; +//// [23.tsx]
; - + +//// [24.tsx]
stuff
; + +//// [25.tsx]
stuff
; + +//// [26.tsx]
>; + +//// [27.tsx] >; + +//// [28.tsx] ; + +//// [29.tsx] ; + +//// [30.tsx] }; + +//// [31.tsx] ; -//// [jsxInvalidEsprimaTestSuite.jsx] +//// [1.jsx] > ; +//// [2.jsx] ; - < ; +//// [3.jsx] + < ; a / > ; - }/> - , - ; -; -; +//// [8.jsx] +; +//// [9.jsx] ; b.c > ; +//// [10.jsx] ; c > ; +//// [11.jsx] ; - < .a > ; +//// [12.jsx] + < .a > ; a > ; +//// [13.jsx] ; +//// [14.jsx] ; [foo] > ; a[foo] > ; +//// [15.jsx] ; ['foo'] > ; a['foo'] > ; -; -; -var x =
one
two
;; -var x =
one
/* intervening comment */ /* intervening comment */
two
;; -
{"str"}}; - id="b" />; -
>; -
; - -
stuff
...props}>; -
stuff
...props}>; - ->; - >; +//// [16.jsx] +;; +//// [17.jsx] +;; +//// [18.jsx] +var x =
one
,
two
; +; +//// [19.jsx] +var x =
one
/* intervening comment */, /* intervening comment */
two
; +; +//// [20.jsx] +
{"str"}}; +//// [21.jsx] +; +//// [22.jsx] +
; +"app" > ; +//// [23.jsx] +
; +//// [24.jsx] +
stuff
; +{ + props; +} + > ; +//// [25.jsx] +
stuff
; +{ + props; +} + > ; +//// [26.jsx] +>; +//// [27.jsx] + >; +//// [28.jsx] ; +; +//// [29.jsx] ; -}; - /*hai*//*hai*/asdf/>;; +; +//// [30.jsx] +}; +//// [31.jsx] +; diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.symbols b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.symbols index 35d58dbff95..f2389f2e3e7 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.symbols +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.symbols @@ -1,113 +1,150 @@ -=== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx === +=== tests/cases/conformance/jsx/1.tsx === declare var React: any; ->React : Symbol(React, Decl(jsxInvalidEsprimaTestSuite.tsx, 0, 11)) +>React : Symbol(React, Decl(1.tsx, 0, 11)) ; +=== tests/cases/conformance/jsx/2.tsx === ; >a : Symbol(unknown) +=== tests/cases/conformance/jsx/3.tsx === <:a />; +No type information for this code.=== tests/cases/conformance/jsx/4.tsx === ; >a : Symbol(unknown) ->b : Symbol(b, Decl(jsxInvalidEsprimaTestSuite.tsx, 5, 2)) +>b : Symbol(b, Decl(4.tsx, 0, 2)) +=== tests/cases/conformance/jsx/5.tsx === ; >a : Symbol(unknown) +=== tests/cases/conformance/jsx/6.tsx === ; >a : Symbol(unknown) >b : Symbol(unknown) +=== tests/cases/conformance/jsx/7.tsx === ; >a : Symbol(unknown) >a : Symbol(unknown) +=== tests/cases/conformance/jsx/21.tsx === ; >span : Symbol(unknown) ->className : Symbol(className, Decl(jsxInvalidEsprimaTestSuite.tsx, 22, 5)) +>className : Symbol(className, Decl(21.tsx, 0, 5)) +>id : Symbol(id, Decl(21.tsx, 0, 20)) +=== tests/cases/conformance/jsx/22.tsx ===
; >div : Symbol(unknown) ->className : Symbol(className, Decl(jsxInvalidEsprimaTestSuite.tsx, 23, 4)) +>className : Symbol(className, Decl(22.tsx, 0, 4)) +=== tests/cases/conformance/jsx/23.tsx ===
; >div : Symbol(unknown) +=== tests/cases/conformance/jsx/24.tsx ===
stuff
; >div : Symbol(unknown) >div : Symbol(unknown) +=== tests/cases/conformance/jsx/25.tsx ===
stuff
; >div : Symbol(unknown) >div : Symbol(unknown) + +=== tests/cases/conformance/jsx/26.tsx ===
>; >a : Symbol(unknown) >a : Symbol(unknown) +=== tests/cases/conformance/jsx/27.tsx === >; >a : Symbol(unknown) >a : Symbol(unknown) +=== tests/cases/conformance/jsx/28.tsx === ; >a : Symbol(unknown) ->b : Symbol(b, Decl(jsxInvalidEsprimaTestSuite.tsx, 31, 2)) +>b : Symbol(b, Decl(28.tsx, 0, 2)) +=== tests/cases/conformance/jsx/29.tsx === ; >a : Symbol(unknown) ->b : Symbol(b, Decl(jsxInvalidEsprimaTestSuite.tsx, 32, 2)) +>b : Symbol(b, Decl(29.tsx, 0, 2)) +=== tests/cases/conformance/jsx/30.tsx === }; >a : Symbol(unknown) >a : Symbol(unknown) +=== tests/cases/conformance/jsx/31.tsx === ; >a : Symbol(unknown) +>asdf : Symbol(asdf, Decl(31.tsx, 0, 6)) diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types index f20391339c4..0791b6d9e85 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx === +=== tests/cases/conformance/jsx/1.tsx === declare var React: any; >React : any @@ -7,10 +7,12 @@ declare var React: any; > : any > : any +=== tests/cases/conformance/jsx/2.tsx === ; > : any >a : any +=== tests/cases/conformance/jsx/3.tsx === <:a />; >< : boolean > : any @@ -21,8 +23,8 @@ declare var React: any; > : any > : any +=== tests/cases/conformance/jsx/4.tsx === ; ->;;; : any +>; : any >a : any +> : any +=== tests/cases/conformance/jsx/6.tsx === ; > : any >a : any >b : any +=== tests/cases/conformance/jsx/7.tsx === : any +=== tests/cases/conformance/jsx/16.tsx === ; ->;;var x =
one
two
;;var x =
one
/* intervening comment */
two
;;
{"str";};;
;
;
stuff
;
stuff
;>; >;;;};; : any +>; : any >a : any > : any >a : any +> : any +=== tests/cases/conformance/jsx/17.tsx === ; ->;var x =
one
two
;;var x =
one
/* intervening comment */
two
;;
{"str";};;
;
;
stuff
;
stuff
;>; >;;;};; : any +>; : any >a : any >b : any +> : any +=== tests/cases/conformance/jsx/18.tsx === var x =
one
two
;; +>x : any +>
one
two
: any >
one
: any >div : any >div : any @@ -149,7 +173,10 @@ var x =
one
two
;; >div : any >div : any +=== tests/cases/conformance/jsx/19.tsx === var x =
one
/* intervening comment */
two
;; +>x : any +>
one
/* intervening comment */
two
: any >
one
: any >div : any >div : any @@ -157,71 +184,97 @@ var x =
one
/* intervening comment */
two
;; >div : any >div : any +=== tests/cases/conformance/jsx/20.tsx ===
{"str";}; >{"str";} : any >a : any >"str" : "str" >a : any +=== tests/cases/conformance/jsx/21.tsx === ; -> : any >span : any >className : string +>id : string +=== tests/cases/conformance/jsx/22.tsx ===
; ->
div : any >className : true +>"app"> : boolean +>"app" : "app" +> : any +=== tests/cases/conformance/jsx/23.tsx ===
; >
: any >div : any >props : any +=== tests/cases/conformance/jsx/24.tsx ===
stuff
; ->
stuff
stuff
div : any >div : any +>props : any +>> : boolean +> : any +> : any +=== tests/cases/conformance/jsx/25.tsx ===
stuff
; ->
stuff
stuff
div : any >props : any >div : any +>props : any +>> : boolean +> : any +> : any + +=== tests/cases/conformance/jsx/26.tsx === >; >> : any >a : any >a : any +=== tests/cases/conformance/jsx/27.tsx === >; > > : any >a : any >a : any +=== tests/cases/conformance/jsx/28.tsx === ; ->;;};; : any +>; : any >a : any >b : any +> : any + +=== tests/cases/conformance/jsx/29.tsx === ; ->;};; : any +>; : any >a : any >b : boolean >< : boolean > : any > : any +> : any + +=== tests/cases/conformance/jsx/30.tsx === }; >} : any >a : any >a : any +=== tests/cases/conformance/jsx/31.tsx === ; -> : any >a : any -> : any -> : any -> : any -> : any +>asdf : true diff --git a/tests/baselines/reference/jsxMultilineAttributeStringValues.js b/tests/baselines/reference/jsxMultilineAttributeStringValues.js new file mode 100644 index 00000000000..5904a08bdc6 --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeStringValues.js @@ -0,0 +1,16 @@ +//// [jsxMultilineAttributeStringValues.tsx] +const a = ; +const b = ; + + +//// [jsxMultilineAttributeStringValues.jsx] +var a = ; +var b = ; diff --git a/tests/baselines/reference/jsxMultilineAttributeStringValues.symbols b/tests/baselines/reference/jsxMultilineAttributeStringValues.symbols new file mode 100644 index 00000000000..e2f1e19edea --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeStringValues.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/jsxMultilineAttributeStringValues.tsx === +const a = ; +>input : Symbol(unknown) + +const b = ; +>input : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxMultilineAttributeStringValues.types b/tests/baselines/reference/jsxMultilineAttributeStringValues.types new file mode 100644 index 00000000000..b9e1b99267f --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeStringValues.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/jsxMultilineAttributeStringValues.tsx === +const a = : any +>input : any +>value : string + + foo: 23 +">; +>input : any + +const b = : any +>input : any +>value : string + +foo: 23 +'>; +>input : any + diff --git a/tests/baselines/reference/jsxMultilineAttributeValuesReact.js b/tests/baselines/reference/jsxMultilineAttributeValuesReact.js new file mode 100644 index 00000000000..25b46a1ff37 --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeValuesReact.js @@ -0,0 +1,17 @@ +//// [jsxMultilineAttributeValuesReact.tsx] +declare var React: any; +const a = ; +const b = ; +const c = ; + + +//// [jsxMultilineAttributeValuesReact.js] +var a = React.createElement("input", { value: "\nfoo: 23\n" }); +var b = React.createElement("input", { value: '\nfoo: 23\n' }); +var c = React.createElement("input", { value: '\nfoo: 23\\n\n' }); diff --git a/tests/baselines/reference/jsxMultilineAttributeValuesReact.symbols b/tests/baselines/reference/jsxMultilineAttributeValuesReact.symbols new file mode 100644 index 00000000000..39252554e16 --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeValuesReact.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/jsxMultilineAttributeValuesReact.tsx === +declare var React: any; +>React : Symbol(React, Decl(jsxMultilineAttributeValuesReact.tsx, 0, 11)) + +const a = ; +>input : Symbol(unknown) + +const b = ; +>input : Symbol(unknown) + +const c = ; +>input : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxMultilineAttributeValuesReact.types b/tests/baselines/reference/jsxMultilineAttributeValuesReact.types new file mode 100644 index 00000000000..2d5dd820b21 --- /dev/null +++ b/tests/baselines/reference/jsxMultilineAttributeValuesReact.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/jsxMultilineAttributeValuesReact.tsx === +declare var React: any; +>React : any + +const a = : any +>input : any +>value : string + +foo: 23 +">; +>input : any + +const b = : any +>input : any +>value : string + +foo: 23 +'>; +>input : any + +const c = : any +>input : any +>value : string + +foo: 23\n +'>; +>input : any + diff --git a/tests/cases/compiler/jsxMultilineAttributeStringValues.tsx b/tests/cases/compiler/jsxMultilineAttributeStringValues.tsx new file mode 100644 index 00000000000..e5cc60ca653 --- /dev/null +++ b/tests/cases/compiler/jsxMultilineAttributeStringValues.tsx @@ -0,0 +1,7 @@ +// @jsx: preserve +const a = ; +const b = ; diff --git a/tests/cases/compiler/jsxMultilineAttributeValuesReact.tsx b/tests/cases/compiler/jsxMultilineAttributeValuesReact.tsx new file mode 100644 index 00000000000..f2b65bce032 --- /dev/null +++ b/tests/cases/compiler/jsxMultilineAttributeValuesReact.tsx @@ -0,0 +1,11 @@ +// @jsx: react +declare var React: any; +const a = ; +const b = ; +const c = ; diff --git a/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx index 815cd4abb21..599efc358fc 100644 --- a/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx +++ b/tests/cases/conformance/jsx/jsxInvalidEsprimaTestSuite.tsx @@ -1,36 +1,74 @@ // @jsx: preserve +// @filename: 1.tsx declare var React: any; ; +// @filename: 2.tsx ; +// @filename: 3.tsx <:a />; +// @filename: 4.tsx ; +// @filename: 5.tsx ; +// @filename: 6.tsx ; +// @filename: 7.tsx ; +// @filename: 21.tsx ; +// @filename: 22.tsx