'Why md5 import is wrong in React?
Why import wrong here? Got this error:
Issues checking in progress...
ERROR in src/slices/Campaign.ts:3:17
TS2307: Cannot find module 'md5' or its corresponding type declarations.
1 | import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
2 | import axios from "axios";
> 3 | import md5 from "md5";
| ^^^^^
4 |
5 | // Actions
6 |
// package.json
"md5": "^2.3.0",
"md5-hash": "^1.0.1",
"ts-md5": "^1.2.11",
import md5 from "md5";
axios({
method: "post",
url: `api/image`,
data: {
filename: imageFilename,
md5: md5(imageFilename),
},
})
Solution 1:[1]
You need to install @types/md5, a package that contains type definitions for md5.
Packages under the @types scope are from DefinitelyTyped, a community driven effort to provide typescript types for popular JS packages.
This is the type definition for the md5 package: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/md5/index.d.ts
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lifeisfoo |
