Reputation: 153
When compiling any typescript program that just imports mongodb
, i get 12 errors like:
node_modules/mongodb/mongodb.d.ts:3309:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'WritableStream'
To reproduce is simple with node TLS (v16.13.1), & a empty directory, just run:
npm i mongodb typescript
echo "import mongodb from 'mongodb'" > index.ts
npx tsc index
Upvotes: 11
Views: 6591
Reputation: 61
I have to downgrade my @types/node to version 17.0.0
"@types/node": "17.0.0", worked for me
read more: https://github.com/mongodb/node-mongodb-native/pull/3088
Upvotes: 2
Reputation: 1472
i referred this https://github.com/mongodb/node-mongodb-native/pull/3088
npm i @types/[email protected] --save-dev
Upvotes: 7
Reputation: 11
mongodb 4.3.0 fix this issue for me.
I use mongoose but I put "mongodb": "^4.3.0"
in my dependencies to force the update. I don't know if this is the right thing to do but it works while waiting for mongoose to update.
Upvotes: 1
Reputation: 153
Looks like mongodb
npm released 4.3.0 last night (2022-01-06) that now resolves this issue! changelog includes the issue here: #3088
v4 now compiles without these errors!
Upvotes: 4
Reputation: 1232
I'm unable to reproduce your problem in my local environment, so I think it is a problem probably related to some other package in your project.
As suggested on this issue, you should try deleting your package-lock.json
and generating it again with npm.
Upvotes: 0