TypeScript with implicit any is a great dynamic language

status
draft
dsq_thread_id
 
TL;DR: TypeScript is great, and its even better for early development when it doesn't yell at you.
Your data often doesn't come pre-typed and you don't know what the types are without writing some application code first.

Let me start off by saying that I'm a fan of TypeScript. TypeScript with noImplicitAny: false is a pretty great way to target both Node and the browser.
That's why I'm writing this post. I've seen quite a few start projects that have noImplicitAny set to true! The horror.

Isn't any bad?

In the mid to long term, probably. In the short term it's a boon. Embrace the any and write your code as if it's plain JS.
Yes, you can have typescript do it’s best to type-check your plain JS code, but then you lose the ability to incrementally add types to your code unless you want to use the obscure comment syntax.

Exceptions to the rule

  • You know the type now and might forget it later
    • This likely goes without saying but if you know the type, put it in the code.
  • Internal tools
    • These have guaranteed users and a requirement for stability from day 1. It makes sense to spend the time upfront to type the whole codebase from the beginning. No any!
  • Personal preference
    • Some people prefer to start with types. It should go without saying but let's make it explicit: If you are enjoying the process of typing your code up front then go for it! It's your codebase and enjoying programming is key to staying productive.
  • Untrusted contributors
    • I.e. contributors you don’t trust to produce high quality code.