【发布时间】:2022-01-17 11:51:35
【问题描述】:
我的项目中出现此错误。请帮忙:(
node_modules/mongoose/index.d.ts:1:1 - 错误 TS6200:以下标识符的定义与另一个文件中的标识符冲突:NativeDate、NativeError、Mongoose、SchemaTypes、STATES、connection、mongo、version、CastError、集合、连接、错误、QueryCursor、VirtualType、架构、SchemaDefinition、子文档、数组、DocumentArray、缓冲区、ObjectId、Decimal128、查询、mquery、聚合、SchemaType、Promise、PromiseProvider、模型
1 声明模块“猫鼬”{
node_modules/@types/mongoose/index.d.ts:80:1 80 声明模块“猫鼬”{ ~~~~~~~
此文件中存在冲突。 node_modules/mongoose/index.d.ts:1143:5 - 错误 TS2374:“字符串”类型的索引签名重复。
1143 [k: 字符串]: 字符串;
// package.json
{
"name": "whatsapp-bot",
"version": "1.0.0",
"description": "Whatsapp Bot",
"main": "build/index.js",
"scripts": {
"compile": "tsc && node build/index.js",
"dev": "NODE_ENV=dev nodemon -e ts --exec \"npm run compile\"",
"start": "NODE_ENV=prod node build/index.js",
"lint": "eslint . --ext .ts"
},
"repository": "https://github.com/m3rashid/whatsapp-bot.git",
"author": "MD Rashid Hussain <mdrashid.hussain.786.01@gmail.com>",
"license": "MIT",
"devDependencies": {
"@types/mongoose-auto-increment": "^5.0.34",
"@types/node": "16",
"@types/pdfkit": "^0.12.3",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.6.0",
"nodemon": "^2.0.15",
"typescript": "^4.5.4"
},
"dependencies": {
"dotenv": "^11.0.0",
"mongoose": "^6.1.6",
"mongoose-auto-increment": "^5.0.1",
"pdfkit": "^0.13.0",
"venom-bot": "^4.0.4"
}
}
// how i am making schemas/models
import mongoose from "mongoose";
interface LinkDocument extends mongoose.Document {
url: string;
title: string;
description: string;
imageUrl: string;
}
const linkSchema = new mongoose.Schema({
url: String,
title: String,
description: String,
imageUrl: String,
});
const Link = mongoose.model<LinkDocument>("Link", linkSchema);
export default Link;
我想将"skipLibCheck": true 添加到我的tsconfig.json,但后来我在 venom.create() 函数中遇到了其他错误TypeError: Cannot read properties of undefined (reading 'create')
另外,这样,我失去了严格的类型检查,我该怎么办?
【问题讨论】:
标签: node.js typescript mongodb mongoose