Skip to content

Commit 97e7b07

Browse files
committed
Merge pull request #4061 from RyanCavanaugh/fix4060
Correctly identify JSX expressions as identifier parents
2 parents c7a2036 + 9f7e71d commit 97e7b07

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

src/compiler/emitter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
14251425
case SyntaxKind.IfStatement:
14261426
case SyntaxKind.JsxSelfClosingElement:
14271427
case SyntaxKind.JsxOpeningElement:
1428+
case SyntaxKind.JsxSpreadAttribute:
14281429
case SyntaxKind.JsxExpression:
14291430
case SyntaxKind.NewExpression:
14301431
case SyntaxKind.ParenthesizedExpression:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx] ////
2+
3+
//// [modules.d.ts]
4+
5+
declare module 'mod' {
6+
var y: any;
7+
export default y;
8+
}
9+
10+
//// [app.tsx]
11+
import Main from 'mod';
12+
declare var Foo, React;
13+
// Should see mod_1['default'] in emit here
14+
<Foo handler={Main}></Foo>;
15+
// Should see mod_1['default'] in emit here
16+
<Foo {...Main}></Foo>;
17+
18+
19+
20+
//// [app.js]
21+
var mod_1 = require('mod');
22+
// Should see mod_1['default'] in emit here
23+
React.createElement(Foo, {"handler": mod_1["default"]});
24+
// Should see mod_1['default'] in emit here
25+
React.createElement(Foo, React.__spread({}, mod_1["default"]));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/conformance/jsx/modules.d.ts ===
2+
3+
declare module 'mod' {
4+
var y: any;
5+
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
6+
7+
export default y;
8+
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
9+
}
10+
11+
=== tests/cases/conformance/jsx/app.tsx ===
12+
import Main from 'mod';
13+
>Main : Symbol(Main, Decl(app.tsx, 0, 6))
14+
15+
declare var Foo, React;
16+
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
17+
>React : Symbol(React, Decl(app.tsx, 1, 16))
18+
19+
// Should see mod_1['default'] in emit here
20+
<Foo handler={Main}></Foo>;
21+
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
22+
>handler : Symbol(unknown)
23+
24+
// Should see mod_1['default'] in emit here
25+
<Foo {...Main}></Foo>;
26+
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
27+
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/conformance/jsx/modules.d.ts ===
2+
3+
declare module 'mod' {
4+
var y: any;
5+
>y : any
6+
7+
export default y;
8+
>y : any
9+
}
10+
11+
=== tests/cases/conformance/jsx/app.tsx ===
12+
import Main from 'mod';
13+
>Main : any
14+
15+
declare var Foo, React;
16+
>Foo : any
17+
>React : any
18+
19+
// Should see mod_1['default'] in emit here
20+
<Foo handler={Main}></Foo>;
21+
><Foo handler={Main}></Foo> : any
22+
>Foo : any
23+
>handler : any
24+
>Main : any
25+
>Foo : any
26+
27+
// Should see mod_1['default'] in emit here
28+
<Foo {...Main}></Foo>;
29+
><Foo {...Main}></Foo> : any
30+
>Foo : any
31+
>Main : any
32+
>Foo : any
33+
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@jsx: react
2+
//@module: commonjs
3+
4+
//@filename: modules.d.ts
5+
declare module 'mod' {
6+
var y: any;
7+
export default y;
8+
}
9+
10+
//@filename: app.tsx
11+
import Main from 'mod';
12+
declare var Foo, React;
13+
// Should see mod_1['default'] in emit here
14+
<Foo handler={Main}></Foo>;
15+
// Should see mod_1['default'] in emit here
16+
<Foo {...Main}></Foo>;
17+

0 commit comments

Comments
 (0)