[英]TypeScript error importing vue package (vue-cli3 proj)
I have a project with newest dependencies set up wizth CLI 3. I get error when importing font-picker-vue package in my project (package installs successfully though).我有一个带有最新依赖项的项目,设置了 CLI 3。在我的项目中导入font- picker -vue包时出现错误(尽管包安装成功)。
The error: Could not find a declaration file for module 'font-picker-vue'......../node_modules/font-picker-vue/lib/FontPicker.js' implicitly has an 'any' type. Try npm install @types/font-picker-vue if it exists or add a new declaration (.d.ts) file containing declare module font-picker-vue';
错误:
Could not find a declaration file for module 'font-picker-vue'......../node_modules/font-picker-vue/lib/FontPicker.js' implicitly has an 'any' type. Try npm install @types/font-picker-vue if it exists or add a new declaration (.d.ts) file containing declare module font-picker-vue';
Could not find a declaration file for module 'font-picker-vue'......../node_modules/font-picker-vue/lib/FontPicker.js' implicitly has an 'any' type. Try npm install @types/font-picker-vue if it exists or add a new declaration (.d.ts) file containing declare module font-picker-vue';
Did a google search and one of the solution suggested was to add following code in a *.d.ts
file: src进行了谷歌搜索,建议的解决方案之一是在
*.d.ts
文件中添加以下代码: src
declare module 'vuetify/lib' {
import 'vuetify/types/lib'
}
Created a *.d.ts
file in the root of the proj as shown in below image, hoping that it would work, but it did not:在项目的根目录中创建了一个
*.d.ts
文件,如下图所示,希望它可以工作,但它没有:
Next, as suggested SO reply changed import statements to require: const yourModuleName = require('module-name');
接下来,按照建议, SO 回复将导入语句更改为 require:
const yourModuleName = require('module-name');
and also tried installing from npm install -D @types/font-picker-vue
.并尝试从
npm install -D @types/font-picker-vue
。 Both didn't work, @types/font-picker-vue isn't in the npm registry.两者都不起作用,@types/font-picker-vue 不在 npm 注册表中。
I am not sure how to resolve this error.我不确定如何解决此错误。 Can somebody help be get this working.
有人可以帮助得到这个工作。 Any help is apprecited.
任何帮助表示赞赏。 Thanks
谢谢
Create a yourModuleName.d.ts file with the module declaration like this declare module 'vuetify/lib'
then try adding this:创建一个带有像这样的模块声明的 yourModuleName.d.ts 文件
declare module 'vuetify/lib'
然后尝试添加以下内容:
"include": "*.d.ts"
To your tsconfig.json file到您的 tsconfig.json 文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.