我正在尝试在我的项目中的 global.d.ts
中记录库的类型。
我不知道如何指定默认导出应该是具有这样那样的 Prop 的 react 组件。
我发现有关 ComponentClass
的提及,但没有相关信息。
我想它应该是这样的:
declare module 'yes-exporting-component' {
const PieChart: <{
data: { color: string, value: any }[]
}>;
export default PieChart;
}
显然上面的语法是不正确的。
最佳答案
你可以尝试这样做:
declare module 'yes-exporting-component'
{
export interface MyPropType
{
data: { color: string, value: any }[];
}
class PieChart extends React.Component<MyPropType, any>
{
}
export default PieChart;
}
关于typescript - 如何记录外部 react 组件的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44499753/