News for hackers. Stuff that matters.
Re:The Great CoffeeScript to Typescript Migration of 2017 by hombre_fatal on Friday May 15, 2020 @07:22PM (#23198668)
Something you run into when adding Typescript annotations to existing JS / libraries in the wild is when the signature turns out to be:

    function transform(a: number | string): number | "" | false
And it's usually all by accident. And it works because in practice it's used with a `if (!transform(x))` check.

Static typing doesn't just tell you what's going on, but it also helps you keep your implementation honest with your intent. It's also why it's a good habit to annotate top-level functions instead of relying on their inference.

Re:The Great CoffeeScript to Typescript Migration of 2017 by ygra on Saturday May 16, 2020 @04:29AM (#23201517)
You can sometimes use overloads to make it better:

    function transform(a: number): number
    function transform(a: string): false
    function transform(""): ""
Depending on how predictable the output is from the types, of course. But for many things it works better than just using union types everywhere.
Re:The Great CoffeeScript to Typescript Migration of 2017 by realharo on Saturday May 16, 2020 @03:54AM (#23201338)
This is especially true with `| undefined` helping address the billion dollar mistake.