I like the tricks :) – Kasia
Moving authorization from value to type level can make your code simpler and bullet-proof.
const dropDatabase = (performedBy: User) => { if (performedBy.type === 'MEBMER') { // ⛔️ Typo return } // ... } dropDatabase(member) // ⛔️
type User = Admin | Member const dropDatabase = (performedBy: Admin) => { // ... } dropDatabase(member) // ✅ Does not compile
Crafted with 💛 by Riccardo