Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MongoDB driver dependency (TS declarations for ~4.1.0 are full of errors) #456

Open
1 task done
JL102 opened this issue May 17, 2022 · 0 comments
Open
1 task done

Comments

@JL102
Copy link

JL102 commented May 17, 2022

  • 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant