[英]TypeScript error "Could not find a declaration file for module" - unable to fix
I'm normally able to resolve this error easily enough, but this time nothing seems to work.我通常能够很容易地解决这个错误,但这次似乎没有任何效果。
My main.ts
file has this:我的
main.ts
文件有这个:
import locale from 'element-ui/lib/locale/lang/en';
The error:错误:
ERROR in /Volumes/SuperData/Sites/reelcrafter/rc-ts/src/main.ts
6:20 Could not find a declaration file for module 'element-ui/lib/locale/lang/en'. '/Volumes/SuperData/Sites/reelcrafter/rc-ts/node_modules/element-ui/lib/locale/lang/en.js' implicitly has an 'any' type.
Try `npm install @types/element-ui` if it exists or add a new declaration (.d.ts) file containing `declare module 'element-ui';`
4 | import store from './store';
5 | import ElementUI from 'element-ui';
> 6 | import locale from 'element-ui/lib/locale/lang/en';
| ^
7 | import VueDragDrop from 'vue-drag-drop';
8 | import './styles/element-setup.scss';
9 | import './bootstrap/amplify-setup';
No lint errors found
Version: typescript 3.0.1, tslint 5.11.0
In my declarations.d.ts
at root level, I added the following:在根级别的
declarations.d.ts
.d.ts 中,我添加了以下内容:
declare module 'element-ui';
This doesn't fix it.这不能解决它。 Nor does
declare module 'element-ui/*';
也不
declare module 'element-ui/*';
. . How do I fix it?
我如何解决它?
Reproduction repo: https://github.com/ffxsam/repro-element-ts-bug复现仓库: https : //github.com/ffxsam/repro-element-ts-bug
创建一个名为shims-element-ui.d.ts
的声明文件,内容如下:
declare module 'element-ui/*';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.