TypeScript Exercises

I'd never describe problem sets as "fun," but there's a reason teachers assign them. It's one thing to nod your head as you read a book ("yes, that makes sense") but quite another to apply what you've learned. Software is very much a "learn by doing" field. You retain knowledge better when you actively use it.

I would have liked to include exercises in Effective TypeScript but never quite got around to it. Fortunately, there are several excellent sources of TypeScript exercises and puzzles online. Here are a few:

TypeScript Exercises

TypeScript Exercises

I can't recommend Marat Dulin's TypeScript Exercises enough. The problems all build on one another, starting very simple and getting very complex. They have a story and a theme to them that I found thoroughly enjoyable ("CEO's friend Nick told us that if we randomly swap user names from time to time in the community, it would be very funny and the project would definitely succeed!") Marat's latest update includes a hosted version, so you can complete the exercises without leaving your browser. My solutions and commentary on a previous version are here.

Type Challenges

Type Challenges

The Type Challenges project was created by Anthony Fu and others. (It's also available in Chinese!) These challenges are independent puzzles and can be done in any order. Each challenge takes you to a TypeScript playground with infuriating red squiggles that must be fixed. This project is very community-oriented: you're encouraged to submit your solutions and suggest other puzzles. I expect that over time it will grow to include many, many more challenges.

If you've read Effective TypeScript and want to apply what you've learned, these are both great resources. Are there others I've missed? Let me know in the comments!

Like this post? Consider subscribing to my newsletter, the RSS feed, or following me on Twitter.
Effective TypeScript Book Cover

Effective TypeScript shows you not just how to use TypeScript but how to use it well. Now in its second edition, the book's 83 items help you build mental models of how TypeScript and its ecosystem work, make you aware of pitfalls and traps to avoid, and guide you toward using TypeScript’s many capabilities in the most effective ways possible. Regardless of your level of TypeScript experience, you can learn something from this book.

After reading Effective TypeScript, your relationship with the type system will be the most productive it's ever been! Learn more »