为什么在 React 中 md5 import 是错误的?

Why md5 import is wrong in React?

为什么这里输入错误?收到此错误:

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), 
  },
})

您需要安装@types/md5, a package that contains type definitions for md5

@types 范围内的包来自 DefinitelyTyped,这是一项社区驱动的工作,旨在为流行的 JS 包提供打字稿类型。

这是 md5 包的类型定义:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/md5/index.d.ts