You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arktype doesn't work with @date-fns/utc UTCDate class. #1568
When passing through the UTCDate and trying to do .toISOString() it blows up with an error Uncaught TypeError: Method Date.prototype.toISOString called on incompatible receiver [object Object]. I wouldn't file an issue, as UTCDate does some dirty tricks underneath, but it works for example in the latest zod, so probably worth to look into it. If you guys could guide me through the possible causes I would be happy to contribute. Thanks for help in advance.
It throws Method Date.prototype.toISOString called on incompatible receiver [object Object]. Using a plain Date succeeds. A second-level subclass and UTCDate also fail.
A narrow guard could preserve Date subclasses by reference, but that aliases the input, so a mutating morph could change the original. Invoking arbitrary subclass constructors is not generically safe, and re-prototyping a new Date cannot restore subclass private fields.
What cloning contract should Date subclasses follow? I’d like to agree on that before preparing a focused regression test and fix, rather than assume pass-through or plain-Date conversion is intended.
Activity
potatohoney-p commentedon Oct 22, 2026
@stepaniukm, I saw your offer to contribute, and this issue is assigned to @ssalbdivad. Before duplicating any work, is a patch already underway?
This still reproduces with arktype 2.2.9 / @ark/util 0.56.8 on Node 24.19.0, even without date-fns:
It throws
Method Date.prototype.toISOString called on incompatible receiver [object Object]. Using a plain Date succeeds. A second-level subclass and UTCDate also fail.The same cloning path on main at cfded1ae9a38b1da527790bb5698ab2d58d6783d handles the exact Date constructor separately, but subclasses reach Object.create, which preserves their prototype without Date's internal timestamp slot.
A narrow guard could preserve Date subclasses by reference, but that aliases the input, so a mutating morph could change the original. Invoking arbitrary subclass constructors is not generically safe, and re-prototyping a new Date cannot restore subclass private fields.
What cloning contract should Date subclasses follow? I’d like to agree on that before preparing a focused regression test and fix, rather than assume pass-through or plain-Date conversion is intended.
docs(type): cite the issues the release fixes and add the entries it …
ssalbdivad commentedon Oct 22, 2026
@potatohoney-p this will be fixed in our next release!
ssalbdivad commentedon Nov 18, 2026
Fixed in 3.0.0-beta.0 (#1728). Try it with
npm i arktype@next.