-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
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
- is depended on by
-
COMPASS-6254 Investigate changes in NODE-4440: Update tsconfig compile target to more modern JS for bson V5
- Closed