0

I am working on a react project and I have typescript within the project. This is new to me so I am trying to figure out how to fix a type error within my 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.

1
  • 1
    You can define (e: any) or type appropriate for you Commented Apr 16, 2019 at 19:26

1 Answer 1

1

You could do something like this:

// tsconfig.json
{
  "compilerOptions": {
    ...,
    "noImplicitAny": false // <-----
  },
  ...,
}

or define a type to e:

let dragStart = (e: any | unknown)
Sign up to request clarification or add additional context in comments.

1 Comment

I used the second method and defined the variable. it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.