Skip to content

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

Closed
@RyanCavanaugh

Description

@RyanCavanaugh

From @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 * as React from 'react';

import { Button } from './button';

export class App extends React.Component<any, any> {

    render() {
        return <Button />;
    }

}

button.tsx

import * as React from 'react';

export class Button extends React.Component<any, any> {

    render() {
        return <button>Some button</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 (var p in b) 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 (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); if (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(deps, factory);
    }
})(["require", "exports", 'react'], function (require, exports) {
    var React = require('react');
    var App = (function (_super) {
        __extends(App, _super);
        function App() {
            _super.apply(this, arguments);
        }
        App.prototype.render = function () {
            return React.createElement(button_1.Button, null);
        };
        return App;
    })(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

Assignees

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