Skip to content

Incorrect emit when using external module import in JSX tag #3674

Description

From Prabir Shrestha (@prabirshrestha) (thanks!) at #3564 (comment)


Tried building tsc locally and running this.

jake LKG
node ..\bin\tsc.js --jsx react -m umd -t es5 app.tsx button.tsx

app.tsx:

/// <references file="./react.d.ts"/>import*asReactfrom'react';import{Button}from'./button';exportclassAppextendsReact.Component<any,any>{render(){return<Button/>;}}

button.tsx

import*asReactfrom'react';exportclassButtonextendsReact.Component<any,any>{render(){return<button>Somebutton</button>;}}

The output app.js does not seem to set the button as a dependency.

/// <references file="./react.d.ts"/>var__extends=(this&&this.__extends)||function(d,b){for(varpinb)if(b.hasOwnProperty(p))d[p]=b[p];function__(){this.constructor=d;}d.prototype=b===null ? Object.create(b) : (__.prototype=b.prototype,new__());};(function(deps,factory){if(typeofmodule==='object'&&typeofmodule.exports==='object'){varv=factory(require,exports);if(v!==undefined)module.exports=v;}elseif(typeofdefine==='function'&&define.amd){define(deps,factory);}})(["require","exports",'react'],function(require,exports){varReact=require('react');varApp=(function(_super){__extends(App,_super);functionApp(){_super.apply(this,arguments);}App.prototype.render=function(){returnReact.createElement(button_1.Button,null);};returnApp;})(React.Component);exports.App=App;});

This makes button_1 undefined. Even with -m amd it doesn't seem to work. Am I missing something here or is this a bug?

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions