logoalt Hacker News

qcorettoday at 4:58 PM1 replyview on HN

All Temporal objects are easily (de)serializable, though. `.toString` and `Temporal.from` work great.


Replies

VanCodingtoday at 5:04 PM

That's not what I mean. Even though it is serializable, it's still not the same when you serialize/deserialize it.

For example `JSON.parse(JSON.stringify(Temporal.PlainYearMonth.from({year:2026,month:1}))).subtract({ years: 1})` won't work, because it misses the prototype and is no longer an instance of Temporal.PlainYearMonth.

This is problematic if you use tRPC for example.

show 4 replies