pro-components
pro-components copied to clipboard
🐛[BUG]: Cannot find module 'history' or its corresponding type declarations.
🐛 bug 描述
When building a project with @ant-design/pro-components, we are getting Cannot find module 'history' or its corresponding type declarations.
📷 复现步骤
git clone https://github.com/maifeeulasad/react-pipeline.git
git checkout 3d5c8aed68657d576ee14ce65315a37284eec3e8
yarn
yarn build // <-- this will cause you error
Running this application in dev mode doesn't cause any trouble (yarn start).
Full error message:
node_modules/@ant-design/pro-layout/es/utils/getBreadcrumbProps.d.ts:2:20 - error TS2307: Cannot find module 'history' or its corresponding type declarations.
2 import type H from 'history';
~~~~~~~~~
🏞 期望结果
It should have built without issues
💻 复现代码
© 版本信息
- ProComponents 版本:
^2.6.34 - umi 版本
n/a - 浏览器环境
Google Chrome: 118.0.5993.118 (Official Build) (64-bit) - 开发环境
Windows / WSL2 / Ubuntu 22.04
🚑 其他信息
- Related issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/50526#issue-783271331
- This can also be resolved by setting
"skipLibCheck": true,for typescript compiler
以下的 Issues 可能会帮助到你 / The following issues may help you
- [#7573][🐛[BUG] Cannot find module 'packages/utils/es' or its corresponding type declarations.][77%]
Here is the related source code referene:
- https://github.com/ant-design/pro-components/blob/beef05775051059d47c3d8ca60b888278695cc94/packages/layout/src/utils/getBreadcrumbProps.tsx#L8
- https://github.com/ant-design/pro-components/blob/beef05775051059d47c3d8ca60b888278695cc94/packages/layout/src/utils/getBreadcrumbProps.tsx#L23-L27
这个问题是由于缺少history模块导致的。你可以尝试以下解决方法:
-
确保你已经安装了
history模块。你可以使用以下命令安装它:npm install history -
如果你使用的是TypeScript,还需要安装与
history模块相对应的类型声明。使用以下命令安装:npm install @types/history -
如果你已经安装了
history模块和类型声明,但仍然出现问题,可以尝试设置TypeScript编译器的"skipLibCheck": true选项。这个选项可以跳过类型检查,但请注意,这可能会导致其他潜在的类型错误被忽略。在你的
tsconfig.json文件中添加以下配置:{ "compilerOptions": { "skipLibCheck": true } }
希望这些解决方法能够帮助你解决问题!如果还有其他问题,请随时提问。
We should add it to pro-components's dependencies list don't you think?