Typescript-wise a NodeJS.ReadableStream may not ".pipe" into GridFSBucketWriteStream

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: TypeScript
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      What problem are you facing?

      In my application i have a variable of type NodeJS.ReadableStream. I  .pipe() its content into an instance of GridFSWriteStream which I created with bucket.openUploadStream.

      This does actually run without problems (when I suppress the TS error) but Typescript would not let me compile it. It says "Types of parameters 'chunk' and 'str' are incompatible. Type 'string' is not assignable to type 'Buffer'." In fact, GridFSWriteStream's write method defines the first argument as Buffer whereas NodeJS.ReadableStream defines the first argument for its pipe-target's write method as Uint8Array | string. Buffer is a sub-class of Uint8Array so they don't match up in this way.

      By the way the example written in the [ upgrade-to-4 document|https://github.com/mongodb/node-mongodb-native/blob/4.0/docs/CHANGES_4.0.0.md] is written in the exact same way as my code and this does not compile

      What driver and relevant dependency versions are you using?

      Latest mongodb package. 4.1.0

      Steps to reproduce?

      Typescript-Playground example

            Assignee:
            Unassigned
            Reporter:
            Tobias Barth
            None
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: