Correctly identify JSX expressions as identifier parents

This commit is contained in:
Ryan Cavanaugh 2015-07-28 13:49:39 -07:00
parent 32bec3b3e7
commit fc9b10eeb6
5 changed files with 84 additions and 0 deletions

View File

@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.IfStatement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.PostfixUnaryExpression:

View File

@ -0,0 +1,20 @@
//// [tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx] ////
//// [modules.d.ts]
declare module 'mod' {
var y: any;
export default y;
}
//// [app.tsx]
import Main from 'mod';
declare var Foo, React;
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>
//// [app.js]
var mod_1 = require('mod');
// Should see mod_1['default'] in emit here
React.createElement(Foo, {"handler": mod_1["default"]});

View File

@ -0,0 +1,23 @@
=== tests/cases/conformance/jsx/modules.d.ts ===
declare module 'mod' {
var y: any;
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
export default y;
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
}
=== tests/cases/conformance/jsx/app.tsx ===
import Main from 'mod';
>Main : Symbol(Main, Decl(app.tsx, 0, 6))
declare var Foo, React;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>React : Symbol(React, Decl(app.tsx, 1, 16))
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>handler : Symbol(unknown)

View File

@ -0,0 +1,26 @@
=== tests/cases/conformance/jsx/modules.d.ts ===
declare module 'mod' {
var y: any;
>y : any
export default y;
>y : any
}
=== tests/cases/conformance/jsx/app.tsx ===
import Main from 'mod';
>Main : any
declare var Foo, React;
>Foo : any
>React : any
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>
><Foo handler={Main}></Foo> : any
>Foo : any
>handler : any
>Main : any
>Foo : any

View File

@ -0,0 +1,14 @@
//@jsx: react
//@module: commonjs
//@filename: modules.d.ts
declare module 'mod' {
var y: any;
export default y;
}
//@filename: app.tsx
import Main from 'mod';
declare var Foo, React;
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>