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

`AbstractCursor[Symbol.asyncIterator]` is wrongly typed

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.1.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 2
    • Not Needed

      What problem are you facing?

      We have our own cursor interface that basically whitelists certain operations and we use that in our code base instead of the official one but after updating to driver v4 we can no longer assign `FindCursor` to our cursor because the `Symbol.asyncIterator` type of `AbstractControl` is wrong.

      What driver and relevant dependency versions are you using?

      Version 4

      Steps to reproduce?

      This type:

      class AbstractCursor<TSchema = any> {
        // ...
        [Symbol.asyncIterator](): AsyncIterator<TSchema | null>;
        // ...
      }
      

      Should be:

      class AbstractCursor<TSchema = any> {
        // ...
        [Symbol.asyncIterator](): AsyncIterator<TSchema>;
        // ...
      }
      

      If `TSchema` CAN be `null`, then it's up to the caller to state so. The async iterator can never yield null unless the input type can be null and that's defined by TSchema.

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            joao.dias@themill.io Joao Dias
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: