Node.js 升级到Mongo 4.0时出错,尝试升级时遇到typescript错误

Node.js 升级到Mongo 4.0时出错,尝试升级时遇到typescript错误,node.js,typescript,mongodb,express,mongoose,Node.js,Typescript,Mongodb,Express,Mongoose,我想将mongodb从3.4升级到4.0。我正在使用angularjs。 类型脚本版本-3.5.1 角度版本-1.5.8 猫鼬版本-5.12.1 我收到打字错误。在所有具有类似实现的文件中 error TS2344: Type 'DExperience' does not satisfy the constraint 'Document<any, {}>'. Types of property 'model' are incompatible. Type '{ <

我想将mongodb从3.4升级到4.0。我正在使用angularjs。 类型脚本版本-3.5.1 角度版本-1.5.8 猫鼬版本-5.12.1

我收到打字错误。在所有具有类似实现的文件中

 error TS2344: Type 'DExperience' does not satisfy the constraint 'Document<any, {}>'.
  Types of property 'model' are incompatible.
    Type '{ <T extends Model<any, {}>>(name: string): T; (name: string): Model<DExperience, {}>; }' is not assignable to type '{ <T extends Model<any, {}>>(name: string): T; (name: string): Model<Document<any, {}>, {}>; }'.

RawVendor、RawExperience、Dvendor和DExperience的类型

import mongoose from 'mongoose';
import { DDatabaseInstance, RawDatabaseInstance } from './database-instance';

export interface RawVendor {
  name?: string;
  description?: string;
  createdBy?: mongoose.Types.ObjectId | string;
  url?: string;
  city?: string;
  isVisible?: boolean;
}
export interface RawExperience {
  name?: string;
  vendor?: mongoose.Types.ObjectId | string;
  description?: string;
  vendorName?: string;
  order?: number;
}

export interface DVendor extends DDatabaseInstance, RawVendor {
  validateSync: (paths?: string[]) => any;
}

export interface DExperience extends DDatabaseInstance, RawExperience {
  validateSync: (paths?: string[]) => any;
}
下面是database-instance.ts

import mongoose from 'mongoose';
import { Timestamps } from './timestamps';

/**
 * A wrapper type around raw hashes that will exist on either POJO database objects or on `mongoose.Document`s.
 */
export interface RawDatabaseInstance extends Timestamps {
  _id: mongoose.Types.ObjectId;
}

/**
 * A wrapper type around a non-POJO `mongoose.Document`
 */
export interface DDatabaseInstance extends mongoose.Document {
  _id: mongoose.Types.ObjectId;
  id: string;

  get(path: string): any;
}

timestamp.ts

export interface Timestamps {
  createdAt: Date;
  updatedAt: Date;
}

这就是我出错的地方


export interface MVendor extends mongoose.Model<DVendor> {}

export interface MExperience extends mongoose.Model<DExperience> {}


导出接口MVendor扩展了mongoose.Model{}
导出接口经验扩展了mongoose.Model{}

您是否也升级了
@types/mongodb
包?如果您已经这样做了,那么您可能需要共享package.json和发生错误的代码-否则很难提供帮助。我已经添加了详细信息,如果我还需要添加@cdimitroulas,请告诉我您是否可以共享
DVendor
DExperience
类型?也更新了类型@cdimitroulas,我希望这有助于我仍然无法复制您的代码,因为不清楚DDatabaseInstance类型应该是什么或它来自哪里

export interface MVendor extends mongoose.Model<DVendor> {}

export interface MExperience extends mongoose.Model<DExperience> {}