Learning TypeScript

| View comments on Hacker News

TypeScript is one of my favorite languages. It is fast, portable, has a great ecosystem, and the language itself is pleasant to work with. It has flaws, but I cannot think of a more versatile language. With TypeScript (and JavaScript), you can write:

  • Web applications
  • iOS/Android mobile apps
  • macOS/Windows/Linux desktop apps
  • Scripts
  • Backends
  • Games

I can’t think of another language so omni-present today. In a way, it’s like C. JavaScript, like C, can run anywhere since every platform has a web browser.

I’ve spent a lot of time becoming better at TypeScript, so I thought I’d compile and share some resources that have helped me over the years.

Unfortunately, TypeScript is complex. First, since it compiles to JavaScript, you need to learn that first. If you’re planning on writing frontend applications you’ll need to also learn HTML/CSS and Browser/DOM APIs. For backend you’ll need to understand NodeJS (or Bun/Deno).

Learning JavaScript is a pretty difficult task, even if you’re an experienced programmer. It has a strange inheritance model, it’s single-threaded, and the ecosystem evolves very quickly. I found the following to help me gain a better understanding of JavaScript:

Now, onto TypeScript! There are two things to look at: programming with TypeScript, and writing type-level TypeScript.

Reading through the TypeScript Handbook helped me understand the core features of the language.

The more difficult part is type-level TypeScript. This refers to writing programs in the type system to generate other types. This is where the strenght of TypeScript lies, since it allows you to precisely express the types of your program. Type-level TypeScript is also a large part of what made the language successful, since it allowed complex, dynamic, JavaScript types to be represented accurately.

The TypeScript Handbook has a section on type-level programming. This is a great reference, but I found the Type-Level TypeScript course to be the best resource. Matt Pocock, who is well-known in the TypeScript world, also has a series called Total TypeScript. I’m sure it’s execellent, but it costs hundreds of dollars, so it’s hard for me to recommend.

For additional challenges I’ve found Type Challenges to be excellent, especially with the VS Code extension.

Additional Resources

  • TypeScript on Exercism
  • Effective TypeScript
  • Runtimes:
    • Deno: Run TypeScript without compiling!
    • Bun: Similar to Deno. Also excellent.
  • Cool libraries:
    • Zod: Validate TypeScript types at runtime
    • ts-pattern: Pattern-matching for TypeScript
    • Astro: Tool that excells at static site generation with amazing TypeScript support
    • Remeda: Lodash for TypeScript
    • XState: Over-complicated state machines in TypeScript

Recent posts from blogs that I like

Japonisme in painting: 1889-1918

More influence in paintings by van Gogh, Pierre Bonnard, Paul Gauguin, the Nabis sculptor Georges Lacombe, Helen Hyde, and Colin Campbell Cooper.

via The Eclectic Light Company

Large tech companies don't need heroes

Large tech companies operate via systems. What that means is that the main outcomes - up to and including the overall success or failure of the company - are driven by a complex network of processes and incentives. These systems are outside the control of any particular person. Like the parts of a l...

via Sean Goedecke

How StrongDM's AI team build serious software without even looking at the code

via Simon Willison