TypeScript was the first time I ever used a static language without feeling like it was getting in the way or I was losing the power of a dynamic language. So no, they didn't learn their mistake from using Python, they were just coaxed into using an incredible language since, barring masochism, you must compile from something into JavaScript nowadays, and TypeScript is an absolute pleasure.
- Type inference for the laziest. Hands down better than Scala, Swift, or Rust. The only language I've ever used that can infer recursive functions:
function factorial(n: number) {
if (n == 0 || n == 1) return 1;
else n * factorial(n - 1)
}
- You can define mix-typed maps without a sweat:
const defaults = { debug: false, title: 'Banana', width: 100 }- And as a bonus you can suck the type out for later use:
type Settings = typeof defaults
- You can mix types without the compiler demanding umpteen incantations.- Gloriously simple union types.
- Regex types are coming! (e.g. all strings that look like a URL)
- You can type the API of some hidden dynamically-typed insanity if needed.
- You get a REPL for free, and it's pretty easy to debug production code if you haven't mangled all your names.
- Haven't figured how to type something? Want to prototype something quickly? No worries! Your code will still compile.