Merge pull request #4061 from RyanCavanaugh/fix4060

Correctly identify JSX expressions as identifier parents
This commit is contained in:
Ryan Cavanaugh
2015-07-29 14:25:04 -07:00
5 changed files with 105 additions and 0 deletions
+1
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.JsxSpreadAttribute:
case SyntaxKind.JsxExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ParenthesizedExpression:
@@ -0,0 +1,25 @@
//// [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>;
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
//// [app.js]
var mod_1 = require('mod');
// Should see mod_1['default'] in emit here
React.createElement(Foo, {"handler": mod_1["default"]});
// Should see mod_1['default'] in emit here
React.createElement(Foo, React.__spread({}, mod_1["default"]));
@@ -0,0 +1,28 @@
=== 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)
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
@@ -0,0 +1,34 @@
=== 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
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
><Foo {...Main}></Foo> : any
>Foo : any
>Main : any
>Foo : any
@@ -0,0 +1,17 @@
//@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>;
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;