score:9

Accepted answer

This type of error can occur when you do not have definition files for exported variables. Those Highcharts extensions still require them - you might want to read more about importing modules without d.ts here: https://github.com/Urigo/meteor-static-templates/issues/9 - it might change in the future.

You need to create a d.ts file for the extensions. For highcharts-more this is my file:

/// <reference path="index.d.ts" />

declare var HighchartsMore: (H: HighchartsStatic) => HighchartsStatic;

declare module "highcharts/highcharts-more" {
    export = HighchartsMore;
}

reference path points to standard DefinietelyTyped Highcharts file from here https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/highcharts/highcharts.d.ts It allows to use type from Highcharts.d.ts because initializing will need proper typing for initializing extension:

HighchartsMore(Highcharts);

And finally don't forget to include all d.ts files by defining tsconfig or writing reference path in your files.

score:2

remove these lines from webpack.config.js:

plugins: [ new webpack.ProvidePlugin({ Highcharts: 'highcharts', HighchartsMore: 'highcharts/highcharts-more', HighchartsExporting: 'highcharts/modules/exporting' }) ]

install typings file for highcharts using this:

npm install --save @types/highcharts

change your import statements to following:

import * as Highcharts from 'highcharts'; import HighchartsMore = require('highcharts/highcharts-more'); HighchartsMore(Highcharts);


Related Query

More Query from same tag