News for hackers. Stuff that matters.
Re:Rules to avoid common extended inline assembly mistakes by smitelli on Saturday December 21, 2024 @10:02AM (#42480070)
Is that vanilla JavaScript or TypeScript? I had always thought that one of the main benefits of TS is that it would probably yell about the first case. (I currently only dabble in the JS world.)
Re:Rules to avoid common extended inline assembly mistakes by zdragnar on Saturday December 21, 2024 @12:02PM (#42480763)
The spread syntax is native to JavaScript. TS wouldn't complain about the first case, because as the parent said, it is a valid operation.

TS only complains about valid operations if there's some potential mistake due to ambiguity, usually when relying on to strong conversions such as adding a string and an array together or some other nonsense.

Re:Rules to avoid common extended inline assembly mistakes by mst on Sunday December 22, 2024 @06:33AM (#42485741)
TS would require you to have attrs typed as object|null rather than object before you even got to that line if you wanted to be able to pass a null value to the function/whatever.

It wouldn't complain about the ... usage itself because ...null is well defined and therefore not a type error.

(it would I think complain about trying to apply ... to something that isn't allowed, though I don't recall making that particular mistake yet in TS code to find out)

Though also, trivial example is trivial - I was looking for the simplest thing that was valid code and let me illustrate the general concept.