Four words to avoid in TypeScript writing

I've written many words about TypeScript and I'm sure I've read even more. Here are four words that make me cringe every time I see them. If you write about TypeScript, please steer clear of these!

  1. "Typescript"

    It's not Typescript. It's TypeScript. Capital T, capital S. Fun fact: it's also JavaScript, capital J, capital S. I thought about ending my post here, this one bugs me so much! If you want to be taken seriously, you need to spell the name of the language correctly. The most egregious example of "Typescript" I know of this is the title of the r/typescript subreddit. (I've requested that this be fixed several times, but to no avail.)

  2. "strongly-typed"

    This one is hyphenated, sorry. I don't like it because no one can agree on what "strongly-typed" means. The TypeScript types that look "strong" to you coming from a Java background might look weak to a Haskell developer. Or to someone who's been using TypeScript a bit longer. And can types that go away at runtime really be considered strong?

    When you write "strongly typed," perhaps you mean to write "statically typed" (which TypeScript is) or "sound" (which it isn't)? Adding to the confusion, a weak type is something very specific in TypeScript, and it's probably not the opposite of the "strong types" that you have in mind.

  3. "advanced"

    Expertise in programming is less about using "advanced" features and more about learning how to effectively use the basic building blocks of your language. To me, using the word "advanced" when discussing features like conditional types implies that that the more you use these features, the more "advanced" you are as a TS programmer. I prefer the word "fancy" (as in "fancy types") since that has more accurate connotations about how often you really need to use these features. After all, the first rule of generics is to avoid them if you can.

  4. "cast"

    The correct term for the expression x as number is "type assertion". I don't like the word "cast" because in most languages (C, C++, Java, Rust, …), a cast can have an effect at runtime. In C, for example, (int)f will convert a float into an int by rounding down. But because TypeScript types are erased at runtime, the as number can't possibly have an effect. If you look at the generated JS in the TypeScript playground, you can see this plainly. It's called a "type assertion" because you're asserting that the value already has the type you say it does. You're not "casting" it into that type. Item 9 of Effective TypeScript, Prefer Type Declarations to Type Assertions, has much more to say about exactly when it's appropriate to use type assertions.

I always try to maintain a positive tone in public forums, and I certainly don't want this post to discourage anyone from writing about Typescript TypeScript. If you've learned something about the language and want to share it online, that's great! I hope you do. But please avoid these four terms!

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. The book's 62 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 »