[英]Typescript error # 70006 with type reference to any
I am working on a react project and I have typescript within the project. 我正在做一个React项目,并且在项目中有打字稿。 This is new to me so I am trying to figure out how to fix a type error within my componenet...
这对我来说是新的,所以我试图弄清楚如何在我的componenet中修复类型错误...
let dragStart = (e) => {
let transferringData = e.dataTransfer.setData("text", e.target.id);
let collectedData = e.dataTransfer.getData("text");
setTimeout(() => {
mainStore.closeWidgetToolbar();
let userWidget = dashboardStore.userDashboards().value.widgets[collectedData];
dashboardService.addWidget(userWidget);
setLayout(dashboardService.getCurrentDashboard().tree);
}, 200);
};
the error is 错误是
src/components/widget-toolbar/WidgetTile.tsx:15:22 - error TS7006: Parameter 'e' implicitly has an 'any' type.
You could do something like this: 您可以执行以下操作:
// tsconfig.json
{
"compilerOptions": {
...,
"noImplicitAny": false // <-----
},
...,
}
or define a type to e
: 或将类型定义为
e
:
let dragStart = (e: any | unknown)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.