TypeScript

I spoke about TypeScript at the NYC ALT.NET user group meeting on July 23.

I have to apologize for the poor quality of this video and the fact that it cuts off at 36 minutes. One of the many things I was reminded of by doing this talk is that the maximum size of a file on a FAT-32 partition is 4 GB. Also for some insane reason, my Canon camera stops recording altogether when it hits 4 GB instead of just quickly starting a new file. Had I formatted the 16 GB SD card that I purchased for the talk as exFAT, it probably would have recorded the whole thing. Thanks so much to the people that saw the talk in person and especially those who were crazy enough to stay for the whole two hours.

Links

Easiest path to TypeScript success in my opinion:

  • Get your JS out of your HTML
  • Rename a .js file to .ts
  • Download definitely types definitions files for any libraries you use. Reference them.
  • Use internal modules to get out of the global namespace. Avoid external modules if at all possible - they are often more complicated than the utility they bring.
  • Turn on "no implicit any" and only type errors that TypeScript complains about.
  • Use minification and unit tests.

Tips

  • Use internal modules - they're awesome for easily getting your code out of the global namespace. The TypeScript team chooses internal modules for TypeScript.
  • Avoid external modules if you can - there is a significant amount of effort to get started with them and they only exhibit practical benefits in extremely large applications (my opinion). Your time would be far better spent first 1.) putting together a build system to minify/bundle your code that uses internal modules and 2.) writing unit tests if you don't have either of those.
  • In TypeScript, the "this" variable works differently in regular functions versus lambdas. Be aware of the difference!