我设置了一个示例项目以使用Highcharts和官方的Highcharts react wrapper,并且可以正常使用,但是当我尝试将其与Typescript一起使用时,出现以下错误:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
这是我将其更新为Typescript后的代码:
import * as React from 'react';
import * as Highcharts from 'highcharts';
import * as HighchartsReact from 'highcharts-react-official';
const options: Highcharts.Options = {
title: {
text: 'Sample chart',
},
series: [
{
type: 'line',
data: [1, 2, 3],
},
],
};
export const UsingHighchartsOfficialVersion = () => (
<div>
<HighchartsReact highcharts={Highcharts} options={options} />
</div>
);
您知道为什么在JS中正常使用Typescript会导致此问题吗?