From 9b7aeaaebd614c8041f57ce89032c41e1addfac7 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Sun, 15 Mar 2020 16:37:18 +0300 Subject: [PATCH 1/8] Improve jsx tag error span --- src/compiler/parser.ts | 11 +++++++++-- tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index bd59db3fe280b..32d22985b43f7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1148,8 +1148,15 @@ namespace ts { parseErrorAtPosition(start, end - start, message, arg0); } - function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void { - parseErrorAt(range.pos, range.end, message, arg0); + function parseErrorAtRange(range: TextRange | any, message: DiagnosticMessage, arg0?: any): void { + let start = range.pos; + if (range.kind === SyntaxKind.PropertyAccessExpression){ + start = range.expression.end - (range.expression.escapedText.length); + } + else if(range.kind === SyntaxKind.Identifier) { + start = range.end - range.escapedText.length; + } + parseErrorAt(start, range.end, message, arg0); } function scanError(message: DiagnosticMessage, length: number): void { diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx new file mode 100644 index 0000000000000..26989001d675a --- /dev/null +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -0,0 +1,7 @@ +let Foo = { + Bar() { + + } +} + +let x = < Foo.Bar >Hello \ No newline at end of file From 8492f76cbe102a22e09ce421e19fc77497b0b65c Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Sun, 15 Mar 2020 17:17:39 +0300 Subject: [PATCH 2/8] Move solution to parseJsxChild func --- src/compiler/parser.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 32d22985b43f7..84ade4c34790e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1148,15 +1148,8 @@ namespace ts { parseErrorAtPosition(start, end - start, message, arg0); } - function parseErrorAtRange(range: TextRange | any, message: DiagnosticMessage, arg0?: any): void { - let start = range.pos; - if (range.kind === SyntaxKind.PropertyAccessExpression){ - start = range.expression.end - (range.expression.escapedText.length); - } - else if(range.kind === SyntaxKind.Identifier) { - start = range.end - range.escapedText.length; - } - parseErrorAt(start, range.end, message, arg0); + function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void { + parseErrorAt(range.pos, range.end, message, arg0); } function scanError(message: DiagnosticMessage, length: number): void { @@ -4552,7 +4545,18 @@ namespace ts { parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag); } else { - parseErrorAtRange(openingTag.tagName, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); + // We want the error to span only property identifier "Foo.Bar" e.g in < Foo.Bar >... + const tag = openingTag.tagName as any; + let start = tag.pos; + if (tag.kind === SyntaxKind.PropertyAccessExpression){ + start = tag.expression.end - (tag.expression.escapedText.length); + } + // We want the error to span only tag identifier "Foo" e.g in < Foo >... + else if(tag.kind === SyntaxKind.Identifier) { + start = tag.end - tag.escapedText.length; + } + + parseErrorAtRange({pos: start, end: tag.end}, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; case SyntaxKind.LessThanSlashToken: From e43276bce34507220a2e93f1713910753cbb6584 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Mon, 16 Mar 2020 23:03:47 +0300 Subject: [PATCH 3/8] Add tests and update baselines --- src/compiler/parser.ts | 2 +- .../errorSpanForUnclosedJsxTag.errors.txt | 27 +++++++++++++++++++ .../reference/errorSpanForUnclosedJsxTag.js | 19 +++++++++++++ .../errorSpanForUnclosedJsxTag.symbols | 20 ++++++++++++++ .../errorSpanForUnclosedJsxTag.types | 26 ++++++++++++++++++ .../compiler/errorSpanForUnclosedJsxTag.tsx | 10 ++++--- 6 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt create mode 100644 tests/baselines/reference/errorSpanForUnclosedJsxTag.js create mode 100644 tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols create mode 100644 tests/baselines/reference/errorSpanForUnclosedJsxTag.types diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 84ade4c34790e..2c59b95a515a2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4556,7 +4556,7 @@ namespace ts { start = tag.end - tag.escapedText.length; } - parseErrorAtRange({pos: start, end: tag.end}, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); + parseErrorAtRange({ pos: start, end: tag.end }, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; case SyntaxKind.LessThanSlashToken: diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt new file mode 100644 index 0000000000000..c8a28af003003 --- /dev/null +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,9): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,14): error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,9): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,13): error TS17008: JSX element 'Baz' has no corresponding closing tag. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,23): error TS1005: ' {} + + let x = < Foo.Bar >Hello + ~~~~~~~~~~~~~~ +!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + ~~~~~~~ +!!! error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. + + let y = < Baz >Hello + ~~~~~~~~~ +!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + ~~~ +!!! error TS17008: JSX element 'Baz' has no corresponding closing tag. + +!!! error TS1005: ' {} + +let x = < Foo.Bar >Hello + +let y = < Baz >Hello + +//// [errorSpanForUnclosedJsxTag.js] +var Foo = { + Bar: function () { } +}; +var Baz = function () { }; +var x = Hello + +let y = Hello; diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols new file mode 100644 index 0000000000000..9ca8f2a7d7c47 --- /dev/null +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === +let Foo = { +>Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 3)) + + Bar() {} +>Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) +} + +let Baz = () => {} +>Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 4, 3)) + +let x = < Foo.Bar >Hello +>x : Symbol(x, Decl(errorSpanForUnclosedJsxTag.tsx, 6, 3)) +>Foo.Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) +>Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 3)) +>Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) + +let y = < Baz >Hello +>Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 4, 3)) + diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.types b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types new file mode 100644 index 0000000000000..eb0617f425cdc --- /dev/null +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === +let Foo = { +>Foo : { Bar(): void; } +>{ Bar() {}} : { Bar(): void; } + + Bar() {} +>Bar : () => void +} + +let Baz = () => {} +>Baz : () => void +>() => {} : () => void + +let x = < Foo.Bar >Hello +>x : any +>< Foo.Bar >Hellolet y = < Baz >Hello : any +>Foo.Bar : () => void +>Foo : { Bar(): void; } +>Bar : () => void + +let y = < Baz >Hello +>< Baz >Hello : any +>Baz : () => void +> : any +> : any + diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx index 26989001d675a..403ffd0cc8f64 100644 --- a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -1,7 +1,9 @@ let Foo = { - Bar() { - - } + Bar() {} } -let x = < Foo.Bar >Hello \ No newline at end of file +let Baz = () => {} + +let x = < Foo.Bar >Hello + +let y = < Baz >Hello \ No newline at end of file From 1e24b6ecc9391190a1febfb22ad94b6b4d2942c8 Mon Sep 17 00:00:00 2001 From: Allan Guwatudde Date: Thu, 19 Mar 2020 18:54:33 +0300 Subject: [PATCH 4/8] Update comment in src/compiler/parser.ts Co-Authored-By: Daniel Rosenwasser --- src/compiler/parser.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2c59b95a515a2..f297b22681e23 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4545,7 +4545,8 @@ namespace ts { parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag); } else { - // We want the error to span only property identifier "Foo.Bar" e.g in < Foo.Bar >... + // We want the error span to cover only 'Foo.Bar' in < Foo.Bar > + const tag = openingTag.tagName as any; let start = tag.pos; if (tag.kind === SyntaxKind.PropertyAccessExpression){ From 1656cebcbc8dd7fe7b61f01f4d292d640ccdd771 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Thu, 19 Mar 2020 19:22:11 +0300 Subject: [PATCH 5/8] Use skipTrivia to check for whitespaces and other trivia --- src/compiler/parser.ts | 16 ++++------------ .../errorSpanForUnclosedJsxTag.errors.txt | 12 ++++++------ .../reference/errorSpanForUnclosedJsxTag.js | 6 +++--- .../compiler/errorSpanForUnclosedJsxTag.tsx | 1 + 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f297b22681e23..05f01ff02e2f5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4546,18 +4546,10 @@ namespace ts { } else { // We want the error span to cover only 'Foo.Bar' in < Foo.Bar > - - const tag = openingTag.tagName as any; - let start = tag.pos; - if (tag.kind === SyntaxKind.PropertyAccessExpression){ - start = tag.expression.end - (tag.expression.escapedText.length); - } - // We want the error to span only tag identifier "Foo" e.g in < Foo >... - else if(tag.kind === SyntaxKind.Identifier) { - start = tag.end - tag.escapedText.length; - } - - parseErrorAtRange({ pos: start, end: tag.end }, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); + // or to cover only 'Foo' in < Foo > + const tag = openingTag.tagName; + const start = skipTrivia(sourceText, tag.pos); + parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; case SyntaxKind.LessThanSlashToken: diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt index c8a28af003003..ccaa6b250c257 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,9): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,14): error TS2304: Cannot find name 'React'. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,14): error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,9): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,13): error TS2304: Cannot find name 'React'. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,13): error TS17008: JSX element 'Baz' has no corresponding closing tag. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,23): error TS1005: ' {} let x = < Foo.Bar >Hello - ~~~~~~~~~~~~~~ -!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + ~~~~~~~ +!!! error TS2304: Cannot find name 'React'. ~~~~~~~ !!! error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. let y = < Baz >Hello - ~~~~~~~~~ -!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + ~~~ +!!! error TS2304: Cannot find name 'React'. ~~~ !!! error TS17008: JSX element 'Baz' has no corresponding closing tag. diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.js b/tests/baselines/reference/errorSpanForUnclosedJsxTag.js index 8b9b6dc793305..c4a7168aaf427 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.js +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.js @@ -14,6 +14,6 @@ var Foo = { Bar: function () { } }; var Baz = function () { }; -var x = Hello - -let y = Hello; +var x = React.createElement(Foo.Bar, null, + "Hello let y = ", + React.createElement(Baz, null, "Hello")); diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx index 403ffd0cc8f64..75002d656481d 100644 --- a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -1,3 +1,4 @@ +// @jsx: react let Foo = { Bar() {} } From 66b750629d071ffa98f575ed7d6137cee895e813 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Thu, 19 Mar 2020 19:38:27 +0300 Subject: [PATCH 6/8] Import React into errorSpanForUnclosedJsxTag.tsx --- .../errorSpanForUnclosedJsxTag.errors.txt | 19 +++++++++---------- .../reference/errorSpanForUnclosedJsxTag.js | 9 +++++++-- .../errorSpanForUnclosedJsxTag.symbols | 19 +++++++++++-------- .../errorSpanForUnclosedJsxTag.types | 3 +++ .../compiler/errorSpanForUnclosedJsxTag.tsx | 3 +++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt index ccaa6b250c257..b7b61cef899a7 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt @@ -1,11 +1,14 @@ -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,14): error TS2304: Cannot find name 'React'. -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(7,14): error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,13): error TS2304: Cannot find name 'React'. -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,13): error TS17008: JSX element 'Baz' has no corresponding closing tag. -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,23): error TS1005: 'Hello ~~~~~~~ -!!! error TS2304: Cannot find name 'React'. - ~~~~~~~ !!! error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. let y = < Baz >Hello ~~~ -!!! error TS2304: Cannot find name 'React'. - ~~~ !!! error TS17008: JSX element 'Baz' has no corresponding closing tag. !!! error TS1005: 'Hello let y = < Baz >Hello //// [errorSpanForUnclosedJsxTag.js] +"use strict"; +exports.__esModule = true; +var react_1 = require("react"); var Foo = { Bar: function () { } }; var Baz = function () { }; -var x = React.createElement(Foo.Bar, null, +var x = react_1["default"].createElement(Foo.Bar, null, "Hello let y = ", - React.createElement(Baz, null, "Hello")); + react_1["default"].createElement(Baz, null, "Hello")); diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols index 9ca8f2a7d7c47..568ea93cdd218 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols @@ -1,20 +1,23 @@ === tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === +import React from "react"; +>React : Symbol(React, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 6)) + let Foo = { ->Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 3)) +>Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 3)) Bar() {} ->Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) +>Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 11)) } let Baz = () => {} ->Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 4, 3)) +>Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 6, 3)) let x = < Foo.Bar >Hello ->x : Symbol(x, Decl(errorSpanForUnclosedJsxTag.tsx, 6, 3)) ->Foo.Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) ->Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 3)) ->Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 11)) +>x : Symbol(x, Decl(errorSpanForUnclosedJsxTag.tsx, 8, 3)) +>Foo.Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 11)) +>Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 3)) +>Bar : Symbol(Bar, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 11)) let y = < Baz >Hello ->Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 4, 3)) +>Baz : Symbol(Baz, Decl(errorSpanForUnclosedJsxTag.tsx, 6, 3)) diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.types b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types index eb0617f425cdc..10775cade4dd2 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.types +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types @@ -1,4 +1,7 @@ === tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === +import React from "react"; +>React : any + let Foo = { >Foo : { Bar(): void; } >{ Bar() {}} : { Bar(): void; } diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx index 75002d656481d..8c51aa242f67e 100644 --- a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -1,4 +1,7 @@ // @jsx: react + +import React from "react"; + let Foo = { Bar() {} } From faafde44147798e14e8823a9a749725701733b69 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Thu, 19 Mar 2020 20:13:17 +0300 Subject: [PATCH 7/8] . --- tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx index 8c51aa242f67e..bfb1387030cbd 100644 --- a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -1,5 +1,4 @@ // @jsx: react - import React from "react"; let Foo = { From fffe487f7798c3685cca391bb1db5149d781ab81 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Thu, 19 Mar 2020 21:17:23 +0300 Subject: [PATCH 8/8] . --- .../reference/errorSpanForUnclosedJsxTag.errors.txt | 7 ++----- tests/baselines/reference/errorSpanForUnclosedJsxTag.js | 9 +++------ .../reference/errorSpanForUnclosedJsxTag.symbols | 4 ++-- .../baselines/reference/errorSpanForUnclosedJsxTag.types | 2 +- tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt index b7b61cef899a7..86bf974d2b2ba 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.errors.txt @@ -1,13 +1,10 @@ -tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(1,19): error TS2307: Cannot find module 'react'. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(9,14): error TS17008: JSX element 'Foo.Bar' has no corresponding closing tag. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(11,13): error TS17008: JSX element 'Baz' has no corresponding closing tag. tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx(11,23): error TS1005: 'Hello let y = < Baz >Hello //// [errorSpanForUnclosedJsxTag.js] -"use strict"; -exports.__esModule = true; -var react_1 = require("react"); var Foo = { Bar: function () { } }; var Baz = function () { }; -var x = react_1["default"].createElement(Foo.Bar, null, +var x = React.createElement(Foo.Bar, null, "Hello let y = ", - react_1["default"].createElement(Baz, null, "Hello")); + React.createElement(Baz, null, "Hello")); diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols index 568ea93cdd218..b45c5370b4d50 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === -import React from "react"; ->React : Symbol(React, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 6)) +declare const React: any +>React : Symbol(React, Decl(errorSpanForUnclosedJsxTag.tsx, 0, 13)) let Foo = { >Foo : Symbol(Foo, Decl(errorSpanForUnclosedJsxTag.tsx, 2, 3)) diff --git a/tests/baselines/reference/errorSpanForUnclosedJsxTag.types b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types index 10775cade4dd2..5fd88448635f4 100644 --- a/tests/baselines/reference/errorSpanForUnclosedJsxTag.types +++ b/tests/baselines/reference/errorSpanForUnclosedJsxTag.types @@ -1,5 +1,5 @@ === tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx === -import React from "react"; +declare const React: any >React : any let Foo = { diff --git a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx index bfb1387030cbd..bd44fd7f8dce1 100644 --- a/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx +++ b/tests/cases/compiler/errorSpanForUnclosedJsxTag.tsx @@ -1,5 +1,5 @@ // @jsx: react -import React from "react"; +declare const React: any let Foo = { Bar() {}