Unfortunately, makecode uses static typescript, which does not support the behaviour you’re trying to accomplish.
Object.keys(x)
is not yet supported whenx
is dynamically a class type. It is supported whenx
was created with an object literal (eg.,{}
or{ a: 1, b: "foo" }
). The order in which properties are returned is order of insertion with no special regard for keys that looks like integer (JavaScript has really counter-intuitive behavior here). When we supportObject.keys()
on class types, the order will be the static order of field definition.
I asked something like this a while back, same outcome