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

TypeScript Collection.indexes() wrong return type

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.2
    • Affects Version/s: None
    • Component/s: Native
    • Labels:
    • Not Needed

      What problem are you facing?

      When I use await collection.indexes(), it claims to return Document, but actually it returns an array. So it should be Document[] or something more specific like IndexDescription[]

      See: https://github.com/mongodb/node-mongodb-native/blob/4.1/src/collection.ts#L1193

       

      What driver and relevant dependency versions are you using?

      mongodb 4.1

      Steps to reproduce?

      Try to use for(const index of await collection.indexes()) in a TypeScript project.
      You will get the error: TS2488: Type 'Document' must have a '[Symbol.iterator]()' method that returns an iterator.

            Assignee:
            daria.pardue@mongodb.com Daria Pardue
            Reporter:
            dominikhb Dominik Herbst
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: