📝 en ~ 4 min

📘 #devbooks: Effective TypeScript: 62 Specific Ways to Improve Your TypeScript

Share this post

If practical books are your type, this is for you! A practical, hands-on guide to write and think better about TypeScript. AND also gives us the background, the trade offs and glances to the internals: “Effective TypeScript: 62 Specific Ways to Improve Your TypeScript” by Dan Vanderkam

The “Effective Books” were a great idea introduced by Scott Meyers with Effective C++. In “Effective Effective Books” he defined ”Effective books consist of a collection of technical essays (“Items”), where each essay’s title comprises advice you should follow, and each essay’s body consists of a rationale for the advice.”

I did not like TypeScript at all, but I was with a growing JavaScript codebase and some my problems, was in the checklist TypeScript promissed solution. I started with an online course but at the same time I look for a “introduction” book. I started some books, and keep ed an eye in this book for “when I really understand what is going on in this files”. I got stuck here and there and then I picked this book and read it front to back.

This type of approach – actionable, focused in the usage is great to learn. And then when you gain more and more insights through ysage you can understand better some advices in the book or even make your own mind. Some advices are opinated, because, well – everything has at least some degree of opinion. And this format is great for all types of developers, from the beginner to the pro and a book to go back again and again.

Item 7: Think of Types as Sets of Values: At runtime, every variable has a single value chosen from JavaScript’s universe of values. There are many possible values […] But before your code runs, when TypeScript is checking it for errors, it just has a type. This is best thought of as a set of possible values. This set is known as the domain of the type.

Item 13: Know the Differences Between type and interface: […] Prefixing interface types with I is common in C#, and this convention made some inroads in the early days of TypeScript. But it is considered bad style today because it’s unnecessary, adds little value, and is not consistently followed in the standard libraries.

Item 48: Use TSDoc for API Comments: Use JSDoc-/TSDoc-formatted comments to document exported functions, classes, and types. This helps editors surface information for your users when it’s most relevant.

“Item 62: Don’t Consider Migration Complete Until You Enable noImplicitAny: Converting your whole project to .ts is a big accomplishment. But your work isn’t done quite yet. Your next goal is to turn on the noImplicitAny option. TypeScript code without noImplicitAny is best thought of as transitional because it can mask real errors you’ve made in your type declarations.”

What is Typescript and when should you use it Dan Vanderkam at CodeNewbie Podcast

“Effective TypeScript, the site for the books has an active blog with new posts from time to time and worth a read as well:

TypeScript Weekly curated by Marius Schulz is a great source to keep up to date with the TypeScript ecossystem.