Skip to content

Commit 8fcca92

Browse files
committed
Merge pull request microsoft#3955 from RyanCavanaugh/fix3928
Correctly identify identifiers inside JSX exprs as expression identifiers
2 parents 32bec3b + 4ac078b commit 8fcca92

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-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.JsxExpression:
14281429
case SyntaxKind.NewExpression:
14291430
case SyntaxKind.ParenthesizedExpression:
14301431
case SyntaxKind.PostfixUnaryExpression:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/jsxImportInAttribute.tsx] ////
2+
3+
//// [component.d.ts]
4+
5+
declare module "Test" {
6+
export default class Text { }
7+
}
8+
9+
//// [consumer.tsx]
10+
/// <reference path="component.d.ts" />
11+
import Test from 'Test';
12+
13+
let x = Test; // emit test_1.default
14+
<anything attr={Test} />; // ?
15+
16+
17+
//// [consumer.jsx]
18+
/// <reference path="component.d.ts" />
19+
var Test_1 = require('Test');
20+
var x = Test_1["default"]; // emit test_1.default
21+
<anything attr={Test_1["default"]}/>; // ?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/consumer.tsx ===
2+
/// <reference path="component.d.ts" />
3+
import Test from 'Test';
4+
>Test : Symbol(Test, Decl(consumer.tsx, 1, 6))
5+
6+
let x = Test; // emit test_1.default
7+
>x : Symbol(x, Decl(consumer.tsx, 3, 3))
8+
>Test : Symbol(Test, Decl(consumer.tsx, 1, 6))
9+
10+
<anything attr={Test} />; // ?
11+
>attr : Symbol(unknown)
12+
13+
=== tests/cases/compiler/component.d.ts ===
14+
15+
declare module "Test" {
16+
export default class Text { }
17+
>Text : Symbol(Text, Decl(component.d.ts, 1, 23))
18+
}
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/consumer.tsx ===
2+
/// <reference path="component.d.ts" />
3+
import Test from 'Test';
4+
>Test : typeof Test
5+
6+
let x = Test; // emit test_1.default
7+
>x : typeof Test
8+
>Test : typeof Test
9+
10+
<anything attr={Test} />; // ?
11+
><anything attr={Test} /> : any
12+
>anything : any
13+
>attr : any
14+
>Test : any
15+
16+
=== tests/cases/compiler/component.d.ts ===
17+
18+
declare module "Test" {
19+
export default class Text { }
20+
>Text : Text
21+
}
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@jsx: preserve
2+
//@module: commonjs
3+
4+
//@filename: component.d.ts
5+
declare module "Test" {
6+
export default class Text { }
7+
}
8+
9+
//@filename: consumer.tsx
10+
/// <reference path="component.d.ts" />
11+
import Test from 'Test';
12+
13+
let x = Test; // emit test_1.default
14+
<anything attr={Test} />; // ?

0 commit comments

Comments
 (0)