../@types/mongodb/index.d.ts:35:18 - 错误 TS2724:“bson”没有名为“ObjectID”的导出成员。您指的是“ObjectId”吗?

Som*_*kar 6 types mongoose mongodb bson

出现此错误。我的打字稿版本是4.5.4和“@types/mongodb”:“〜3.3.1”,“@types/mongoose”:“〜5.5.17”。知道如何解决

../@types/mongodb/index.d.ts:49:74 - error TS2724: '"bson"' has no exported member named 'ObjectID'. Did you mean 'ObjectId'?

49 export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson';
                                                                            ~~~~~~~~

  ../bson/bson.d.ts:939:22
    939 export declare class ObjectId extends BSONValue {
                             ~~~~~~~~
    'ObjectId' is declared here.
Run Code Online (Sandbox Code Playgroud)

pry*_*me0 1

降级到版本 6.8.3 解决了我的问题。我认为当前版本的 mongoose 可能存在错误。或者当前版本与其某些依赖项存在兼容性问题。