wing icon indicating copy to clipboard operation
wing copied to clipboard

`json` can be mutated

Open tsuf239 opened this issue 1 year ago • 0 comments

I tried this:

let a: MutJson = {a: 1, b: 0};
let b = MutJson {a: 1, b: 0};
let c = {a: 1, b: 0};
let d: Json = {a: 1, b: 0};
let e = Json {a: 1, b: 0};

let testMutJson = (x: MutJson) => {
  x.delete("a");
  log(x); // logs { b: 0 } each time :/
};

testMutJson(a);
log(a);
testMutJson(b);
log(b);
testMutJson(c);
log(c);
testMutJson(d);
log(d);
testMutJson(e);
log(e);

This happened:

image

I expected this:

to throw an error for the immutable jsons

Is there a workaround?

No response

Anything else?

No response

Wing Version

0.82.1

Node.js Version

No response

Platform(s)

MacOS

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.

tsuf239 avatar Aug 07 '24 10:08 tsuf239