I like the tricks :) – Kasia
Avoid branching by limiting the number of types that flow in the program
type PostCode = string | number const shipTo = (postCode: PostCode) => { if (typeof postCode === "string") { // format string } else { // ⛔️ Need to branch // format number } }
type PostCode = string const shipTo = (postCode: PostCode) => { // ✅ Only need to format string }
Crafted with 💛 by Riccardo