Update MongoDB driver dependency (TS declarations for ~4.1.0 are full of errors)
JL102 opened this issue · comments
-
I'm submitting a ...
-
Maintenance request
-
Summary
The TypeScript declarations for the 4.1.x MongoDB driver are full of errors, so it is currently impossible to build a TS project which has connect-mongo as a dependency.
I made a fork for my own purposes and changed"peerDependencies": { "mongodb": "~4.1.0" }
to"peerDependencies": { "mongodb": ">=4.1.0" }
, and it appears to work fine. Alternatively, updating to either~4.5.0
or~4.6.0
(to avoid potential future breaking changes) would be great. -
Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Excerpt from the compilation errors:
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'.
Type '{ (): void; (chunk: Buffer): void; (callback: Callback<void | GridFSFile>): void; (chunk: Buffer, callback: Callback<void | GridFSFile>): void; (chunk: Buffer, encoding: BufferEncoding): void; (chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: (() => void) | undefined): this; (data: string | Uint8Array, cb?: (() => void) | undefined): this; (str: string, encoding?: BufferEncoding | undefined, cb?: (() => void) | undefined): this; }'.
3309 end(chunk: Buffer, encoding: BufferEncoding): void;
~~~
node_modules/mongodb/mongodb.d.ts:3310:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'Writable'.
Type '{ (): void; (chunk: Buffer): void; (callback: Callback<void | GridFSFile>): void; (chunk: Buffer, callback: Callback<void | GridFSFile>): void; (chunk: Buffer, encoding: BufferEncoding): void; (chunk: any, encoding: BufferEncoding, cb?: (() => void) | undefined): this; }'.
3310 end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): void;
~~~
node_modules/mongodb/mongodb.d.ts:3310:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'WritableStream'.
Type '{ (): void; (chunk: Buffer): void; (callback: Callback<void | GridFSFile>): void; (chunk: Buffer, callback: Callback<void | GridFSFile>): void; (chunk: Buffer, encoding: BufferEncoding): void; (chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: (() => void) | undefined): this; (data: string | Uint8Array, cb?: (() => void) | undefined): this; (str: string, encoding?: BufferEncoding | undefined, cb?: (() => void) | undefined): this; }'.
3310 end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): void;
Found 12 errors in the same file, starting at: node_modules/mongodb/mongodb.d.ts:3305
P.S. these errors occur even when you add node_modules
to the exclude list in tsconfig.json.
Thanks!