[英]Lerna, yarn, and Typescript: Cannot find module or its corresponding type declarations
[英]Vue js 3 with TypeScript Cannot find module 'xxxxxx' or its corresponding type declarations
我使用 vue js 2 制作了一个分页插件。在另一个项目中使用 Vue 3 和 TypeScript 时出现错误。 错误消息是“找不到模块‘l-分页’或其相应的类型声明”。 当我下载了几个不同的项目时,它们运行良好。 我正在创建的插件中是否存在问题,或者是否有解决此错误的不同方法(“找不到模块‘l-分页’或其相应的类型声明”)?
Shims-vue.d.ts
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
配置文件
{
"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"
]
}
添加到 tsconfig.json:
"types": ["node"]
并安装@types/node:
npm install --save-dev @types/node
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.