Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-4108): improve return type for withTransaction() #3236

Merged
merged 1 commit into from
May 12, 2022

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented May 6, 2022

Description

The withTransaction() function signature implies that withTransaction() returns the same value that the user-provided callback returns but that is incorrect.

Reported in Automattic/mongoose#9919

What is changing?

Function signature for withTransaction() maintains the T argument but goes unused. Added tests for asserting the expected outcomes.

What is the motivation for this change?

Fixes the type bug, but also adds documentation to the three possible outcomes of the function.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken force-pushed the NODE-4108/withTransaction-return-type branch from a73ca1d to 54e309e Compare May 6, 2022 20:21
@@ -36,6 +36,14 @@ declare global {
}

namespace Mocha {
interface SuiteFunction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a request for changes just wanting to understand the rationale for including these 2 definitions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our metadata UI also allows specifying filters at the describe level, only in the 3 argument form of title, metadata, function So this just prevents type issues when using a metadata object in describe or context. I just don't think we've used metadata at the suite level much before or we haven't needed it in TS test yet. But the transactions tests will always need to filter up to 4.2 maybe 4.4 so it makes sense to specify it higher up.

@durran durran added the Team Review Needs review from team label May 9, 2022
@durran durran marked this pull request as ready for review May 9, 2022 16:54
@baileympearson baileympearson merged commit 48e0e6e into main May 12, 2022
@baileympearson baileympearson deleted the NODE-4108/withTransaction-return-type branch May 12, 2022 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants