Fork me on GitHub
#squint
<
2023-03-06
>
Andrea11:03:50

Hi, just noticed that squint doesn’t respect property order when emitting objects defined via the syntax {:key-1 "foo" :key-2 "bar"} . I believe some js code do relies on the order in which js objects literals are written, like https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.ts#L8-L104. Couldn’t find a reliable source of truth whether/which ECMA specification do enforce a predictable property order https://stackoverflow.com/questions/30076219/does-es6-introduce-a-well-defined-order-of-enumeration-for-object-properties How do we feel about that? @borkdude did this come out yet somewhere (couldn’t find in squint issues)

borkdude11:03:46

@andrea712 hah, wow, really? well, the issue is that even when reading that map, the order is already lost since it's a clojure hash-map

Andrea11:03:03

yeah, I thought so

borkdude11:03:23

we could fix that maybe with #ordered/map {:foo "foo"} or so, in squint itself, can be done outside of the reader

borkdude12:03:02

but only if there is no other way and JS really relies on this

Andrea12:03:23

I’ll dig a bit deeper, I can work around the issue for the moment, thank you

borkdude12:03:00

I guess you could construct a JS object from a non-literal map as a workaround

borkdude12:03:53

user=> (js-obj "a" 1 "b" 2)
#js {:a 1, :b 2}

borkdude12:03:14

maybe js-obj isn't supported yet in squint? if not, we should add it

Andrea14:03:54

it’s not supported on squint 0.0.10

borkdude14:03:48

ok adding it now...

borkdude14:03:01

v0.0.12 released

Andrea14:03:36

amazing:zap:

Brandon Stubbs06:03:20

I just ran into this issue, is this something you are happy an issue is raised for? (To support #ordered/map) The js-obj solution works too (Is this the final way you think of supporting this?)