
TypeScript 4 Design Patterns and Best Practices
By :

When a runtime assertion fails, then the whole program should fail and notify the developers of that error case. This is because assertions represent irrecoverable errors and we should be able to find out the source of the problem early. By using them in places where you expect a value or a type to exist at runtime, you uncover bugs.
Black-box reuse means that you use a component without knowing its internals. All you possess is a component interface. At that time, you test it without knowing or expecting a particular library or a function to trigger because this is concealed. With black-box reuse, you can debug and test code many times and in alternative scenarios, and it closely follows the Liskov substitution principle.