cljs-dev

souenzzo 2025-08-21T13:37:33.517299Z

I'm already dealing with this in another way on my side This works for me: (extend-type UUID Object (toJSON [this] (str this))) Do you think it would be bad to add a toJSON on UUID type in core.cljs? https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L11783 Can't we test this in the "coal mine" or something like?

borkdude 2025-08-21T13:38:32.731589Z

what would toUUID do?

souenzzo 2025-08-21T13:40:57.364459Z

during JSON.stringify, if toJSON method exists, it will be called instead of "toString" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

p-himik 2025-08-21T13:41:54.232109Z

It's totally fine to do it in your own app. Totally not fine to do it in a library or anywhere else where people don't have control over it.

p-himik 2025-08-21T13:43:42.849039Z

> during JSON.stringify, if toUUID method exists, it will be called instead of "toString" Are you sure?.. That page does not mention toUUID.

souenzzo 2025-08-21T13:43:48.040889Z

I know 🙂 But I'm asking, why not do this in the core? current behavior is clearly not the ideal. I still don't rule out the possibility of doing this in clj->js

souenzzo 2025-08-21T13:44:19.333409Z

ooops s/toUUID/toJSON/g

p-himik 2025-08-21T13:45:15.764719Z

Well, as David has said - doing that now is probably a bad idea. It's a breaking change. And not an unlikely one given that it's not a random internal thing but a public method that's expected to be overridden.