Support toJSON method on objects is required for accurate JS/TS to JSON translation.
toJSON can define custom representation of any JS object wich may not match the object itself.
If toJSON is not respected by JSON schema generators then generated schema may deviate from actual JSON representation of a JS object.
Support
toJSON
method on objects is required for accurate JS/TS to JSON translation.toJSON
can define custom representation of any JS object wich may not match the object itself. IftoJSON
is not respected by JSON schema generators then generated schema may deviate from actual JSON representation of a JS object.Example: https://github.com/mongodb/js-bson/blob/main/src/objectid.ts#L202