Wrong TypeScript return type for session.withTransaction

XMLWordPrintableJSON

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

      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
          173 kB
          Nikita Savchenko
        2. image-2023-07-14-11-19-04-629.png
          78 kB
          Nikita Savchenko
        3. image-2023-07-14-10-59-36-952.png
          29 kB
          Nikita Savchenko
        4. image-2023-07-14-10-53-07-475.png
          42 kB
          Nikita Savchenko
        5. image-2023-07-13-10-09-05-060.png
          193 kB
          Nikita Savchenko
        6. image-2023-07-04-09-19-56-315.png
          20 kB
          Nikita Savchenko
        7. image-2023-07-04-09-18-53-123.png
          216 kB
          Nikita Savchenko

              Assignee:
              Durran Jordan
              Reporter:
              Nikita Savchenko
              None
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: