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

ObjectId.equals type union is missing undefined and null

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • bson-6.0.0
    • Affects Version/s: None
    • Component/s: None
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      What problem are you facing?

      We've been migrating away from a custom `idEquals` function in a large codebase towards `ObjectId.equals`. Our custom function allowed for `undefined` ids and it looks like `.equals` allows for them as well when reading the function body, but the Typescript definition doesn't include `undefined` or `null` in the type union. This blocks the ability to pass a potentially undefined `ObjectId` to `.equals` and leads to awkward ternaries or other hacks that shouldn't be necessary from the caller.

      What driver and relevant dependency versions are you using?

      mongodb: 5.7.0

      Steps to reproduce?

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            justinvdhooft@gmail.com Justin Vanderhooft
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: