我正在尝试使用打字稿来绘制高图。我还加载了包含highmaps的highcharts类型。
class InvestmentChart extends React.Component {
componentDidMount() {
Highcharts.mapChart("investment", {
chart: {
...
干杯
看到现场here。
基于readme,看起来你需要这样做:
import * as Highcharts from 'highcharts/highmaps';
代替:
import * as Highcharts from 'highcharts';
我尝试了这个in CodeSandbox,它似乎超过了你被卡住的地步。
DefinitelyTyped似乎有一些Highmaps的类型,虽然它们已经过时了。以下导入Highmaps的方法似乎在运行时在CodeSandbox中获得前一个方法,并将使用以下类型:
import * as Highcharts from "highcharts";
import MapFactory = require("highcharts/modules/map");
(MapFactory as any)(Highcharts);
New CodeSandbox。在本地,我仍然得到一个类型错误,因为过时的声明(subtitle
无法识别),但你可以//@ts-ignore
它。我不知道为什么CodeSandbox上没有出现此错误。