TypeScript rule: If a function requires something, the function's type...
TypeScript rule: If a function requires something, the function's type signature should require it.
This sounds obvious and reasonable, but I often see objects with nullable fields passed to functions which actually require the field.
Here's why: Developers declare a type once and try to reuse it everywhere. This can lead to overly broad types and low type safety.
Solution: If a field is required in some contexts, declare a dedicated type that requires the field. This way, the function's signature doesn't "lie".
If a field is required, I shouldn't have to check if the field is undefined inside the function. The function's type signature should ensure it is passed an object that contains the required fields.

Of course, this rule is a tradeoff: I have to write a little extra code (an extra TypeScript type).
But extending an interface or using a type intersection requires very little extra code - I only have to specify the fields that are different.
And now, the type's signature tells the whole truth. 👍