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

Wrong TypeScript return type for session.withTransaction

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • 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?

      Take a look at this: https://github.com/mongodb/node-mongodb-native/blob/ccc5e3042b0f52d990a517bca224434bdfbd4728/src/sessions.ts#L457

      This typescript definition is wrong, even when compared to the method's readme:

      `async withTransaction<T = void>(fn: WithTransactionCallback<T>, options?: TransactionOptions
        ): Promise<Document | undefined>`

      This is the actual data returned, and as you can see, it is nowhere close to the Document type:

      To work around this problem, I had to create a wrapper method which redefines types.

      Please help in fixing the type definition. Thanks.

        1. image-2023-07-22-15-16-57-157.png
          image-2023-07-22-15-16-57-157.png
          173 kB
        2. image-2023-07-14-11-19-04-629.png
          image-2023-07-14-11-19-04-629.png
          78 kB
        3. image-2023-07-14-10-59-36-952.png
          image-2023-07-14-10-59-36-952.png
          29 kB
        4. image-2023-07-14-10-53-07-475.png
          image-2023-07-14-10-53-07-475.png
          42 kB
        5. image-2023-07-13-10-09-05-060.png
          image-2023-07-13-10-09-05-060.png
          193 kB
        6. image-2023-07-04-09-19-56-315.png
          image-2023-07-04-09-19-56-315.png
          20 kB
        7. image-2023-07-04-09-18-53-123.png
          image-2023-07-04-09-18-53-123.png
          216 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            zitros.lab@gmail.com Nikita Savchenko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: