Reactjs Typescript:属性类型';数据';不相容

Reactjs Typescript:属性类型';数据';不相容,reactjs,typescript,types,dependencies,Reactjs,Typescript,Types,Dependencies,各位。我花了4天多的时间试图解决这个问题,但没有结果,所以决定寻求帮助 我有一个为期一年的项目的副本(不是我的,需要完成它),它构建时没有任何错误,但当我从svn获得源代码并运行时 npm i 在整个项目中,我遇到了错误:属性“数据”的类型不兼容。 我肯定知道原因是在node_模块中的某个地方,但无法修复它 我已经尝试通过npm shrinkwrap从工作副本生成package.json,使用npm collect,手动安装所有需要的包。还可以尝试将typeroot添加到tsconfig.jso

各位。我花了4天多的时间试图解决这个问题,但没有结果,所以决定寻求帮助

我有一个为期一年的项目的副本(不是我的,需要完成它),它构建时没有任何错误,但当我从svn获得源代码并运行时

npm i

在整个项目中,我遇到了错误:属性“数据”的类型不兼容。 我肯定知道原因是在node_模块中的某个地方,但无法修复它

我已经尝试通过
npm shrinkwrap
从工作副本生成package.json,使用npm collect,手动安装所有需要的包。还可以尝试将typeroot添加到tsconfig.json-nothing

第一部分

const renderContent = (
  widget: IDashboardWidget,
  data: IDashboardWidgetData | INodeInfoData,
) => {
  ...
  const {type: type, displayOptions, thresholds = [], id} = widget;
  {
    console.log(data);
    return <Chart id={id} displayOptions={displayOptions} type={type} data={data} thresholds={thresholds}/>;
  }
  ...
};

export default renderContent;
interface IComponetProps {
  id: string;
  type: WidgetType;
  thresholds?: Array<{
    value: number;
    severity: string;
  }>;
  displayOptions: IDashboardWidgetDisplayOptions,
  data: object[];
}
},

反应:

"react": "^16.3.2"

我几乎可以肯定,依赖关系中存在问题,但我可能错了。非常感谢您的建议和帮助。

似乎InodeInfo数据不是数组,不能作为对象[]传递。请提供更多信息。

好吧,我停止使用react 16.3.2和typescript 2.8.3版本,我仍然不知道哪个软件包需要更改源代码,但这有助于:

    return <Chart id={id} displayOptions={displayOptions}  type={widgetType} 
            data={data as IDashboardWidgetData}  thresholds={thresholds}/>;
返回;

此代码适用于大约半年前安装的node_模块,但如果我再次运行npm,就会出现此错误。正如我所说的,问题在于InodeInfo数据没有成为数组。但对于您的代码示例,我无法提供更好的答案。
"react": "^16.3.2"
    return <Chart id={id} displayOptions={displayOptions}  type={widgetType} 
            data={data as IDashboardWidgetData}  thresholds={thresholds}/>;