Vue js 3 with TypeScript 找不到模块'xxxxxx'或其对应的类型声明



我用vue js 2制作了一个分页插件。当在另一个项目中使用Vue 3和TypeScript时,我得到一个错误。错误信息是"无法找到模块'l-pagination'或其相应的类型声明"。当我下载了几个不同的项目时,它们运行得很好。我正在创建的插件中是否存在问题,或者是否有不同的方法来解决此错误("无法找到模块'l-pagination'或其相应的类型声明")?

Shims-vue.d.ts

declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

tsconfig.json

{
"compilerOptions": {
"noImplicitAny": false,
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}

add to tsconfig.json:

"types": ["node"]

和安装@types/node:

npm install --save-dev @types/node

相关内容

  • 没有找到相关文章

最新更新