In this blog post, we explore what unions and intersections of object types can be used for in TypeScript.
Roughly, TypeScript is JavaScript plus type information. The latter is removed before TypeScript code is executed by JavaScript engines. Therefore, writing and deploying TypeScript is more work. Is that added work worth it? In this blog post, I’m going to argue that yes, it is. Read it if you are skeptical about TypeScript but interested in giving it a chance.
Read this blog post if you are a JavaScript programmer and want to get a rough idea of what using TypeScript is like (think first step before learning more details). You’ll get answers to the following questions:
Note: This blog post does not explain why TypeScript is useful. If you want to know more about that, you can read my TypeScript sales pitch.
node --watch
Now that Node.js has built-in support for TypeScript, we can use it as the foundation of simple playgrounds that let us interactively explore TypeScript code.
In this blog post, we explore how we can test that complicated TypeScript types work as expected. To do that, we need assertions at the type level and other tools.
The TypeScript handbook makes an interesting statement: “Often, the checks in a conditional type will provide us with some new information. Just like narrowing with type guards can give us a more specific type, the true branch of a conditional type will further constrain generics by the type we check against.”
In this blog post, we’ll see that this goes further than you may think.
I have published the repository nodejs-type-stripping
which demonstrates how to implement a package with a bin script that is written directly in TypeScript (no transpilation).
never
in TypeScriptIn this blog post, we look at the special TypeScript type never
which, roughly, is the type of things that never happen. As we’ll see, it has a surprising number of applications.
T[]
vs. Array<T>
in TypeScriptIn this blog post, we explore two equivalent notations for Arrays in TypeScript: T[]
and Array<T>
. I prefer the latter and will explain why.
In this blog post, we examine how TypeScript handles JavaScript symbols at the type level.
If you want to refresh your knowledge of JavaScript symbols, you can check out chapter “Symbols” of “Exploring JavaScript”.