解决Could not find a declaration file for module 'vue-xxx'问题
Could not find a declaration file for module 'vue-json-pretty'. '/Users/apple/Desktop/workspace/H5/vue/packapp/node_modules/vue-json-pretty/lib/vue-json-pretty.js' implicitly has an 'any' type. Try npm i --save-dev @types/vue-json-pretty
if it exists or add a new declaration (.d.ts) file containing declare module 'vue-json-pretty';
解决办法:
方法一:
为了避免这个问题,我只是用标准 require() 替换它
This error occured because of vue-xxxxxx has been generated in JavaScript.
const vue-xxxxxx = require('vue-xxxxxx');
// import { vue-xxxxxx } from 'vue-xxxxxx'
方法二:
为了避免这个问题,我只是在 tsconfig.json 中修改了这些行
"noImplicitAny": false,
"allowJs": true,
"compilerOptions" 下面
现在您可以使用 import 语句,如下所示
import { vue-xxxxxx } from 'vue-xxxxxx'
网友评论