简体   繁体   English

打字稿错误#70006,引用任何类型

[英]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.

相关问题 在 TypeScript 中引用推断类型 - Reference an inferred type in TypeScript TypeScript &amp; 是的错误:'参考类型的参数<unknown> ' 不能分配给 'number | 类型的参数参考<number> '</number></unknown> - TypeScript & Yup Error: Argument of type 'Reference<unknown>' is not assignable to parameter of type 'number | Reference<number>' Promise 解析在 TypeScript 中有错误,因为错过了任何类型 - Promise resolve has error in TypeScript because missed any type React typescript 错误:元素隐式具有“任何”类型 - React typescript error: Element implicitly has an 'any' type 为什么要声明类型 <any> 解决未知方法错误? (打字稿) - Why Does Declaring Type <any> Resolve Error with Unknown Method? (Typescript) TypeScript 错误参数“props”隐式具有“any”类型 - TypeScript error Parameter 'props' implicitly has an 'any' type Typescript 错误; 'CellDetails | 类型上不存在任何属性'按钮' 内容单元更新' - Typescript error; any Property 'button' does not exist on type 'CellDetails | ContentCellUpdate' 参考类型在其内部,TypeScript - Reference Type Within itself, TypeScript 打字稿:是否可以引用类型别名 - Typescript: Is it possible to reference type aliases console.log()'ing 类型“any”变量会导致 Typescript 上的错误吗? - Will console.log()'ing type “any” variable cause error on Typescript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM