​TS Handbook and this article are great intros.


  • TypeScript can figure the return type out by looking at the return statements, so we can also optionally leave this off in many cases

  • You really shouldn’t use arrow function as class members. Arrow functions are duplicated in memory for each class instance, while proper method members are written once in your class’s prototype and shared between all instances.

  • any means β€œignore the type”, unknown means β€œwe don’t know the type”, which aren’t the same thing, and for better code you’d rather not know the type than ignore it.

  • You can’t use unknown as a simple replacement for any, that wouldn’t make sense. unkwnown carries the implication that you should not use this variable other than passing it around. Or testing its type to get rid of the β€œunknown” state.

  • Tuples are very useful for simulating multiple returns like React hooks, and other combined values that don't need string object keys



TypeScript’s type hierarchy