ad hoc
Done for one specific case on the spot, rather than as part of a general, reusable approach.
In more detail
Ad hoc property checks scattered through controllers are easy to get wrong and hard to update. Moving them into named type guards makes them reusable and testable.
Related terms
- type predicate — A return type written param is Type, which tells the compiler that when the function returns true, the argument has that type.
Taught in
- Custom Type Predicates: Functions Returning is Type — Production TypeScript