Skip to content

Commit 7c1ef22

Browse files
committed
Merge pull request #5974 from RyanCavanaugh/fix5955
Identify JSX closing tags as identifiers so they emit correctly
2 parents 31f56fd + 05c1703 commit 7c1ef22

File tree

5 files changed

+65
-7
lines changed

5 files changed

+65
-7
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
14531453
case SyntaxKind.ForInStatement:
14541454
case SyntaxKind.ForOfStatement:
14551455
case SyntaxKind.IfStatement:
1456+
case SyntaxKind.JsxClosingElement:
14561457
case SyntaxKind.JsxSelfClosingElement:
14571458
case SyntaxKind.JsxOpeningElement:
14581459
case SyntaxKind.JsxSpreadAttribute:

tests/baselines/reference/tsxPreserveEmit1.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,28 @@ import ReactRouter = require('react-router');
2222

2323
import Route = ReactRouter.Route;
2424

25-
var routes = <Route />;
25+
var routes1 = <Route />;
26+
27+
module M {
28+
export var X: any;
29+
}
30+
module M {
31+
// Should emit 'M.X' in both opening and closing tags
32+
var y = <X></X>;
33+
}
2634

2735

2836
//// [test.jsx]
2937
define(["require", "exports", 'react-router'], function (require, exports, ReactRouter) {
3038
"use strict";
3139
var Route = ReactRouter.Route;
32-
var routes = <Route />;
40+
var routes1 = <Route />;
41+
var M;
42+
(function (M) {
43+
})(M || (M = {}));
44+
var M;
45+
(function (M) {
46+
// Should emit 'M.X' in both opening and closing tags
47+
var y = <M.X></M.X>;
48+
})(M || (M = {}));
3349
});

tests/baselines/reference/tsxPreserveEmit1.symbols

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ import Route = ReactRouter.Route;
1111
>ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 4, 1))
1212
>Route : Symbol(ReactRouter.Route, Decl(react.d.ts, 7, 4))
1313

14-
var routes = <Route />;
15-
>routes : Symbol(routes, Decl(test.tsx, 6, 3))
14+
var routes1 = <Route />;
15+
>routes1 : Symbol(routes1, Decl(test.tsx, 6, 3))
1616
>Route : Symbol(Route, Decl(test.tsx, 2, 45))
1717

18+
module M {
19+
>M : Symbol(M, Decl(test.tsx, 6, 24), Decl(test.tsx, 10, 1))
20+
21+
export var X: any;
22+
>X : Symbol(X, Decl(test.tsx, 9, 11))
23+
}
24+
module M {
25+
>M : Symbol(M, Decl(test.tsx, 6, 24), Decl(test.tsx, 10, 1))
26+
27+
// Should emit 'M.X' in both opening and closing tags
28+
var y = <X></X>;
29+
>y : Symbol(y, Decl(test.tsx, 13, 4))
30+
>X : Symbol(X, Decl(test.tsx, 9, 11))
31+
>X : Symbol(X, Decl(test.tsx, 9, 11))
32+
}
33+
1834
=== tests/cases/conformance/jsx/react.d.ts ===
1935

2036
declare module 'react' {

tests/baselines/reference/tsxPreserveEmit1.types

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,28 @@ import Route = ReactRouter.Route;
1111
>ReactRouter : typeof ReactRouter
1212
>Route : any
1313

14-
var routes = <Route />;
15-
>routes : any
14+
var routes1 = <Route />;
15+
>routes1 : any
1616
><Route /> : any
1717
>Route : any
1818

19+
module M {
20+
>M : typeof M
21+
22+
export var X: any;
23+
>X : any
24+
}
25+
module M {
26+
>M : typeof M
27+
28+
// Should emit 'M.X' in both opening and closing tags
29+
var y = <X></X>;
30+
>y : any
31+
><X></X> : any
32+
>X : any
33+
>X : any
34+
}
35+
1936
=== tests/cases/conformance/jsx/react.d.ts ===
2037

2138
declare module 'react' {

tests/cases/conformance/jsx/tsxPreserveEmit1.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ import ReactRouter = require('react-router');
2323

2424
import Route = ReactRouter.Route;
2525

26-
var routes = <Route />;
26+
var routes1 = <Route />;
27+
28+
module M {
29+
export var X: any;
30+
}
31+
module M {
32+
// Should emit 'M.X' in both opening and closing tags
33+
var y = <X></X>;
34+
}

0 commit comments

Comments
 (0)