Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3871

TypeErrors while using in a Nest & Mongoose enviorment

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.0
    • Affects Version/s: 4.2.2
    • Component/s: None
    • 0
    • Not Needed

      What problem are you facing?

      TypeErrors while using mongodb with mongoose in NestJS emitted from mongodb 

      What driver and relevant dependency versions are you using?

      mongodb - 4.2.2

      mongoose - 6.1.6

      nestjs - 8.2.5

      nodejs - 16.11.1

      Steps to reproduce?

      1. Clone a NestJS Mongo with TypeScript starter template
      2. run `yarn upgrade --latest`
      3. run and error should occour

       

      Logs:

      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 'Writable'.
       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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
       Type 'void' is not assignable to type 'this'.
       'this' could be instantiated with an arbitrary type which could be unrelated to 'void'.
      3309 end(): void;
       ~~~
      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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
       Type 'void' is not assignable to type 'this'.
       'this' could be instantiated with an arbitrary type which could be unrelated to 'void'.
      3309 end(): 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: Buffer, encoding: BufferEncoding, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
      3310 end(chunk: Buffer): 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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
      3310 end(chunk: Buffer): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3311: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: Buffer, encoding: BufferEncoding, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
      3311 end(callback: Callback<GridFSFile | void>): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3311: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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
      3311 end(callback: Callback<GridFSFile | void>): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3312: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: Buffer, encoding: BufferEncoding, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
      3312 end(chunk: Buffer, callback: Callback<GridFSFile | void>): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3312: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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
      3312 end(chunk: Buffer, callback: Callback<GridFSFile | void>): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3313: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: Buffer, encoding: BufferEncoding, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
      3313 end(chunk: Buffer, encoding: BufferEncoding): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3313: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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
      3313 end(chunk: Buffer, encoding: BufferEncoding): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3314: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: Buffer, encoding: BufferEncoding, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
      3314 end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): void;
       ~~~
      node_modules/mongodb/mongodb.d.ts:3314: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, callback: Callback<...>): void; }' is not assignable to type '{ (cb?: () => void): this; (data: string | Uint8Array, cb?: () => void): this; (str: string, encoding?: BufferEncoding, cb?: () => void): this; }'.
      3314 end(chunk: Buffer, encoding: BufferEncoding | undefined, callback: Callback<GridFSFile | void>): void;
       ~~~
      [08:38:53] Found 12 errors. Watching for file changes.
      

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            teamnordendev@gmail.com Team Norden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: