Hacker News new | ask | show | jobs
by blubbi2 3628 days ago
Probably easier to just use an assertion library here. E.g.

  assert.ok(element)
2 comments

I wrote a library [1] and a babel plugin [2] (bonus point: is Flow compatible) in order to deal with those cumbersome runtime type checks.

[1] https://github.com/gcanti/tcomb [2] https://github.com/gcanti/babel-plugin-tcomb

Even easier- typescript or flow
Adding a build step adds complexity.
No. Using a weak, dynamically typed language adds complexity. Using a compiler isn't adding complexity.
Except the transpiled code is still dynamically typed. People act like when they started writing Typescript they stopped writing bugs..
First, they don't act like that, and if they do that's dumb.

Second, how is that different from writing in a statically-typed language like Haskell/Rust/what have you and then compiling down to assembly which is for all intents and purposes dynamically typed? We do it hoping to gain safety from the typing, but do we lose the type safety in the machine code? (We don't, the type-safe language rules out compiling to certain classes of erroneous code.)