如何记录外部反应组件的类型



我正在尝试在我的项目中记录global.d.ts库中库的类型。

我不知道如何指定默认导出应该是具有这样那样的道具的反应组件。

我发现了关于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;
}

最新更新