我有一个为期一年的项目的副本(不是我的,需要完成它),它构建时没有任何错误,但当我从svn获得源代码并运行时
在整个项目中,我遇到了错误:属性“数据”的类型不兼容。
我肯定知道原因是在node_模块中的某个地方,但无法修复它。
我已经尝试通过工作副本生成package.json
npm shrinkwrap
,使用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[];
}
Type '{ id: string; displayOptions: IDashboardWidgetDisplayOptions; type: WidgetType.line | WidgetType....' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<Pick<IChartProps, "data" | "locatio...'.
Type '{ id: string; displayOptions: IDashboardWidgetDisplayOptions; type: WidgetType.line | WidgetType....' is not assignable to type 'Readonly<Pick<Pick<IChartProps, "data" | "location" | "history" | "match" | "staticContext" | "id...'.
Types of property 'data' are incompatible.
Type 'INodeInfoData | { name: string; lat?: string | undefined; lon?: string | undefined; status?: stri...' is not assignable to type 'object[]'.
Type 'INodeInfoData' is not assignable to type 'object[]'.
Property 'push' is missing in type 'INodeInfoData'.
"devDependencies": {
"@fortawesome/fontawesome": "^1.1.8",
"@types/classnames": "^2.2.3",
"@types/cytoscape": "^3.1.9",
"@types/file-saver": "^1.3.0",
"@types/globalize": "0.0.32",
"@types/highcharts": "^5.0.22",
"@types/jest": "^22.2.3",
"@types/jwt-decode": "^2.2.1",
"@types/lodash": "^4.14.109",
"@types/node": "^9.6.18",
"@types/ramda": "^0.25.29",
"@types/react": "^16.3.14",
"@types/react-click-outside": "^3.0.1",
"@types/react-custom-scrollbars": "^4.0.3",
"@types/react-dates": "^16.0.6",
"@types/react-dom": "^16.0.5",
"@types/react-grid-layout": "^0.16.4",
"@types/react-redux": "^5.0.20",
"@types/react-router-dom": "^4.2.6",
"@types/react-router-redux": "^5.0.14",
"@types/react-sortable-hoc": "^0.6.3",
"@types/react-tabs": "^1.0.4",
"@types/react-toggle": "^4.0.1",
"@types/react-widgets": "^4.1.2",
"@types/recompose": "^0.26.1",
"@types/redux-form": "^7.2.5",
"@types/redux-logger": "^3.0.6",
"@types/socket.io-client": "^1.4.32",
"@types/uuid": "^3.4.3",
"globalize-webpack-plugin": "^2.1.0",
"node-sass": "^4.9.0",
"prettier": "^1.12.1",
"redux-devtools-extension": "^2.13.2",
"redux-logger": "^3.0.6",
"sass-loader": "^7.0.1",
"tslint-config-prettier": "^1.13.0",
"typescript": "2.8.3",
"webpack-bundle-analyzer": "^2.13.1"
},
反应:
"react": "^16.3.2"