Skip to content

Import Line from pre-ES6 module being skipped #6372

Description

@erfangc

This TS file, when transpiled to ES5/CommonJS, some how does Not have a require statement for 'highcharts-release'. It does have the proper require statements for React.

(this code compiles with out an error by the way, using highcharts.d.ts provided through tsd, I had to make a few modifications)

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Highcharts = require('highcharts-release');

class Chart extends React.Component<any,any> {

    private chart:HighchartsChartObject;

    constructor(props:any) {
        super(props);
    }

    componentDidMount() {
        const node = ReactDOM.findDOMNode(this);

        var chartOptions = {
            chart: {
                type: 'area',
                renderTo: node as HTMLElement
            },
            title: {
                text: 'Historic and Estimated Worldwide Population Growth by Region'
            },
            subtitle: {
                text: 'Source: Wikipedia.org'
            },
            xAxis: {
                categories: ['1750', '1800', '1850', '1900', '1950', '1999', '2050'],
                tickmarkPlacement: 'on',
                title: null
            },
            yAxis: {
                title: {
                    text: 'Billions'
                },
                labels: {
                    formatter: function ():string {
                        return (this.value / 1000).toString();
                    }
                }
            },
            tooltip: {
                shared: true,
                valueSuffix: ' millions'
            },
            plotOptions: {
                area: {
                    stacking: 'normal',
                    lineColor: '#666666',
                    lineWidth: 1,
                    marker: {
                        lineWidth: 1,
                        lineColor: '#666666'
                    }
                }
            },
            series: [ ... ]
        };

        this.chart = new Highcharts.Chart(chartOptions);
        var axis:HighchartsAxisOptions = {
            id: "stuff",
            opposite: true,
            title: {
                text: "New Axis"
            }
        };
        this.chart.addAxis(axis);
        debugger;
    }

    render() {
        return <div></div>;
    }
}

ReactDOM.render(<Chart/>, document.body);

Excerpt of the transpiled output

var __extends = (this && this.__extends) || function (d, b) {
...
};
var React = require('react');
var ReactDOM = require('react-dom');
var Chart = (function (_super) {
    __extends(Chart, _super);
    function Chart(props) {
        _super.call(this, props);
    }
   ...
})(React.Component);
ReactDOM.render(React.createElement(Chart, null), document.body);
//# sourceMappingURL=Chart.js.map

Notice the absence of the require('highcharts-release'); line

this is my tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "jsx": "react"
    },
    "exclude": [
        "node_modules",
        "jspm_packages"
    ]
}

TypeScript version: 1.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions