mongoose.Types.ObjectId.isValid and mongoose.Types.ObjectId.toHexString missing from type definitions #10678
Labels
typescript
Types or Types-test related issue / Pull Request
Milestone
What is the current behavior?
The
mongoose.Types.ObjectId.isValid
andmongoose.Types.ObjectId.toHexString
types are no longer present in"mongoose": "^5.12.2"
( which resolves to"version": "5.13.8"
)When trying to access any of those properties I get a:
Property 'isValid' does not exist on type 'ObjectIdConstructor'.ts(2339)
In
mongoose
s' index.d.ts you got:const ObjectId: ObjectIdConstructor;
pointing to:_ObjectId
pointing to:mongodb.ObjectID
pointing to:export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from "bson";
ObjectID
pointing to nothing.@types/bson
is a folder that has just thepackage.json
, LICENSE and README. The content of itspackage.json
:I have an older repo with the same dependencies, i.e.
"mongoose": "^5.12.2"
, and with that I seem to get a@types/bson
that has anindex.d.ts
in its package. The content of itspackage.json
:Whats the solution here? I tried locking down
mongoose
to a specific version in order to get its dependencies to install, but that didn't work. NPM states that the types for BSON are no longer an independent package. Thoughts?PS:
bson
does not provide its own types, as per the description of the latest@types/bson
Also,
mongoose
requires"@types/mongodb": "^3.5.27"
but in my working repo that resolves toAnd in the repo that this doesn't work, it resolves to
Could it be that
@types/mongodb
broke the camel's back?Digging further, it seems that when you go to the landing page on NPM for the
mongodb
types, it says that mongo provides its own types, but when I go in my dependency tree, there is no such type definition file provided bymongodb
, so what is going on?The text was updated successfully, but these errors were encountered: