无法从tsx文件导入函数

a11xaf1n  于 2021-09-08  发布在  Java
关注(0)|答案(1)|浏览(452)

我正在使用react+typescript+webpack。
我正在尝试导入该函数 drawOnCanvasHelper 包裹里 react-financial-charts ,我已正确安装了npm。该函数将从文件中导出:https://github.com/reactivemarkets/react-financial-charts/blob/f5a2ab4b537652770c4ff8a1805678fb149861e9/packages/series/src/stackedbarseries.tsx
我尝试用两种不同的方式导入它:

import { drawOnCanvasHelper } from "@react-financial-charts/series";
import { drawOnCanvasHelper } from "react-financial-charts";

但是,它们都会生成相同的错误消息:

TS2305: Module '"react-financial-charts"' has no exported member 'drawOnCanvasHelper'.
TS2305: Module '"@react-financial-charts/series"' has no exported member 'drawOnCanvasHelper'.

我不理解这个错误消息,因为该包中的文件肯定会导出该函数。那么,如何正确导入此函数以在项目中使用呢?

rkkpypqq

rkkpypqq1#

看来, /packages/series/src/index.ts 文件,它们仅导出 StackedBarSeriesStackedBarSeriesPropsStackedBarSeries 成分
根据链接:

// index.ts
export * from "./AlternateDataSeries";
export * from "./AlternatingFillAreaSeries";
export * from "./AreaOnlySeries";
export * from "./AreaSeries";
export * from "./markers";
export * from "./LineSeries";
export * from "./CandlestickSeries";
export * from "./OHLCSeries";
export * from "./BarSeries";
export { StackedBarSeries, StackedBarSeriesProps } from "./StackedBarSeries";
export * from "./GroupedBarSeries";
export * from "./KagiSeries";
export * from "./PointAndFigureSeries";
export * from "./RenkoSeries";
export * from "./MACDSeries";
export * from "./BollingerSeries";
export * from "./RSISeries";
export * from "./StochasticSeries";
export * from "./ElderRaySeries";
export * from "./VolumeProfileSeries";
export * from "./ScatterSeries";
export * from "./StraightLine";
export * from "./SARSeries";

因此,您无法获得 drawOnCanvasHelper 功能。虽然他们导出函数,但它可能只用于内部开发人员-最终用户只能访问 StackedBarSeries 阶级和 StackedBarSeriesProps 接口
希望我说的有道理

相关问题