问题描述
我使用 recharts v1.8.5 / @types/recharts v1.8,19 创建了图表。我想升级到最新版本的recharts(v2.0.8),但内部类型似乎还没有准备好。 Typescript 编译器抱怨 PieChartProps
不再从包 recharts
导出。
从捆绑的类型定义中导出饼图:
types/index.d.ts
export { PieChart } from './chart/PieChart';
types/chart/PieChart.d.ts
/// <reference types="react" />
export declare const PieChart: {
new (props: import("./generateCategoricalChart").CategoricalChartProps): {
uniqueChartId: any;
...
}
}
所以 PieChart 似乎对它的 Props 有定义。但是我如何在我自己的组件中使用它呢?我试过了
// not working
import { CategoricalChartProps } from 'recharts/generateCategoricalChart'
// not working
import { Props } from 'recharts/types/chart/PieChart'
--- 更新---
这有效,但看起来有点难看(不清楚它是 PieChartProps)。有没有更好的办法?
import { CategoricalChartProps } from 'recharts/types/chart/generateCategoricalChart'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)