[COMPASS-6254] Investigate changes in NODE-4440: Update tsconfig compile target to more modern JS for bson V5 Created: 26/Oct/22  Updated: 06/Jan/23  Resolved: 06/Jan/23

Status: Closed
Project: Compass
Component/s: None
Affects Version/s: None
Fix Version/s: No version

Type: Investigation Priority: Major - P3
Reporter: PM Bot Assignee: Unassigned
Resolution: Done Votes: 0
Labels: node-driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on NODE-4440 Update tsconfig compile target to mor... Closed
Documentation Changes: Not Needed

 Description   

Use Case

As a node engineer
I want remove manual prototype manipulation and function constructor logic.
So that we can use modern JS features, offering a better user experience 

User Impact

  • JS emitted from TS will use class syntax for-of loops will be unmodified etc.

Dependencies

  • The driver type logic.

Unknowns

  • The _bsontype property determines serialization
    • Our driver relies on {{extends { _bsontype: string }}} type logic for preventing BSON type from having their keys be suggested in nested documents, will that still work?
    • _bsontype was defined on the prototype of the function, we cannot maintain that since in newer JS emit syntax the _bsontype will be defined as an instance class property.
      • Will moving it to a getter impact users? Doubtful, it will still be defined on the prototype, non-enumerable, and implicitly readonly since only a getter will be defined.

Acceptance Criteria

Implementation Requirements

  • Change all _bsontype defineProperty calls to get _bsontype() syntax.
    • Consider adding get [Symbol.toStringTag]() that calls the _bsontype getter
  • Remove the this instanceof X logic at the top of each BSON type constructor (it handles when the class is called without "new" which will now be impossible)
  • Timestamp class type info might be cleaned up here, it can override the getter instead of the current manual TS logic to remove the _bsontype from the Long super class

Testing Requirements

  • Verify _bsontype getters are on all type classes

Documentation Requirements

  • DOCSP ticket, API docs, etc

Follow Up Requirements

  • additional tickets to file, required releases, etc


 Comments   
Comment by Rhys Howell [ 06/Jan/23 ]

Doesn't look like this impacts our tools.

Generated at Wed Feb 07 22:42:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.