错误TS6200和错误TS2403:以下标识符的定义与另一个文件中的定义冲突
我正在尝试在打字稿中设置一个节点项目。
导致错误的两个文件:
- node_modules@typesmongooseindex.d.ts
- node_modulesmongooseindex.d.ts
[错误][1][1]:https://i.stack.imgur.com/46vDU.jpg
node_modules/@types/mongoose/index.d.ts:79:1 - 错误 TS6200:以下标识符的定义与另一个文件中的标识符冲突:DocumentDefinition、FilterQuery、UpdateQuery、NativeError、Mongoose、CastError、ConnectionOptions、Collection、Connection、断开连接、连接、连接、断开连接、未初始化、错误、QueryCursor、VirtualType、Schema、SchemaTypeOpts、Subdocument、Array、DocumentArray、Buffer、ObjectIdConstructor、Decimal128、Map、Aggregate、SchemaType、Document、ModelUpdateOptions
79 声明模块“猫鼬”{
node_modules/mongoose/index.d.ts:1:1
1 declare module "mongoose" {
~~~~~~~
Conflicts are in this file.
node_modules/@types/mongoose/index.d.ts:226:14 - error TS2403: Subsequent variable declarations must have the same type. Variable 'SchemaTypes' must be of type 'typeof Types', but here has type 'typeof Types'.
226 export var SchemaTypes: typeof Schema.Types;
~~~~~~~~~~~
回答
Mongoose 包含 TypeScript 类型mongoose@5.11.0,因此您可以删除该包@types/mongoose。
来源:https : //developer.mongodb.com/community/forums/t/schema-error-while-running-backend-server-nestjs-angular/12440/3
- Thank you! Perfect!
THE END
二维码