Hacker News new | ask | show | jobs
by wonderlg 2136 days ago
With your library one has to write types twice.

I understand that it’s not TypeScript’s job at the moment, but it’d be great to enable runtime checks with the flick of a switch without typing extra code.

    function upper(s: string) {
      return s.toUpperCase();
    }
This function could have a nice implicit TypeError instead of “undefined is not a function”
1 comments

I’m not sure what you mean. My library has a `TypeOf` type that lets you extract static type information from validation functions. And calling `toUpperCase` on undefined already results in a TypeError.