Skip to main content

TypeScript

After decades of programming with strongly typed languages (C, C++, Java), the change to TypeScript is a significant shift in terms of what is and isn't possible and why. This TypeScript for Java Developers page from the TypeScript Handbook is a great reference for me whenever jumping back into coding with TypeScript.

The content that follows in this section will be abbreviated notes and code snippets specific to me. Anyone other than me reading this for the purposes of learning about Typescript would be well advised to read the TypeScript Handbook instead.

Basics

tip

TypeScript transpiles to JavaScript so at runtime all of the extra type checking etc has been removed. Stop looking for the TypeScript equivalent of casting! :D Use something like ZOD or Valibot if you need/want runtime type validation.

Managing packages and patching

depcheck or npm-check could be useful (I've not tried either yet) for removing packages which are not used. This isn't the same as npm prune which only removes modules from the node_modules/ folder but not from package.json.