"Effective TypeScript" category

How to iterate over objects in TypeScript

Use let k: keyof T and a for-in loop to iterate objects when you know exactly what the keys will be or Object.entries to iterate over the keys and values of any object.

Use async functions instead of callbacks for asynchronous code

Prefer async/await to raw Promise when possible. They produce more concise, straightforward code and eliminate whole classes of errors.

The different between type and interface in TypeScript

Should you use type or interface? For complex types, you have no choice: you need to use a type alias. But what about the simpler object types that can be represented either way? To answer this question, you should consider consistency and augmentation. Are you working in a codebase that consistently uses interface? Then stick with interface. Does it use type? Then use type.

Apply types to entire function expressions when possible

Consider applying type annotations to entire function expressions, rather than to their parameters and return type. If you're writing the same type signature repeatedly, factor out a function type.