News for hackers. Stuff that matters.
Re:First look: adding type annotations to JavaScript by claytongulick on Thursday March 10, 2022 @10:19PM (#30635727)
What I'm referring to is non-trivial function definitions.

Things with optional parameters that can accept a wide variety of types, async callbacks and async variadic return types.

The hoops you need to jump through to make the compiler happy are absurd.

Re:First look: adding type annotations to JavaScript by kingdomcome50 on Friday March 11, 2022 @11:04AM (#30641555)
Functions like the ones you are describing probably shouldn't exist!

I have no doubt that a sizable portion of these functions' bodies is dedicated to figuring out which type each of our input variables represent (from our wide variety). So now instead of having our editor/compiler help us out, we are now actually writing code to figure it out ourselves... this is more absurd (and less efficient).

And FWIW, using union types makes it trivial to denote that a function can accept a wide variety of types in a type-safe way. But guess what you will be doing first thing in the function body? Discriminating that union!

Re:First look: adding type annotations to JavaScript by jestar_jokin on Friday March 11, 2022 @01:26AM (#30636940)
Sounds like a problem with some API trying to make everyone happy.

Could be avoided by having more functions, one for each case.

(Only if you control the code, of course.)