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-6259): replace dynamically assigned length property with a static getter #4173

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

sis0k0
Copy link
Member

@sis0k0 sis0k0 commented Jul 10, 2024

Description

The length property was declared on the BulkOperationBase interface in the @types/mongodb package. With version 4.0, installing @types/mongodb is no longer required. However, the declarations generated in the mongodb package don't have the length property.

What is changing?

The BulkOperationBase type now has a length property. This was the behaviour when using @types/mongodb.

Is there new documentation needed for these changes?

No

What is the motivation for this change?

See this discussion in the Community Forums.

Release Highlight

BulkOperationBase (super class of UnorderedBulkOperation and OrderedBulkOperation) now reports length property in Typescript

The length getter for these classes was defined manually using Object.defineProperty which hid it from typescript. Thanks to @sis0k0 we now have the getter defined on the class, which is functionally the same, but a greatly improved DX when working with types. 🎉

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
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

Thanks so much for jumping on this @sis0k0!

The Object.defineProperty(BulkOperationBase.prototype, 'length' style of declaring class members is no longer needed since we're writing code with class syntax now. This field was overlooked when the driver was rewritten in TS, thanks for catching it and improving things!

src/bulk/common.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken self-assigned this Jul 10, 2024
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 10, 2024
@sis0k0 sis0k0 changed the title fix(NODE-6259): declare dynamically assigned length property fix(NODE-6259): replace dynamically assigned length property with a static getter Jul 11, 2024
@baileympearson baileympearson requested a review from nbbeeken July 11, 2024 14:11
@nbbeeken nbbeeken added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jul 11, 2024
@nbbeeken nbbeeken merged commit 320dde0 into mongodb:main Jul 11, 2024
27 of 29 checks passed
@sis0k0 sis0k0 deleted the sis0k0/declare-missing-property branch July 12, 2024 07:19
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.

2 participants