Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd say that writing this example from the article is a pretty big downside, especially if you had e.g. 20 different cases and not just 2.

```ts const getTableName = (addressType: 'shipping' | 'billing') => { if (addressType === 'shipping') { return 'shipping_addresses' } if (addressType === 'billing') { return 'billing_addresses' } throw new TypeError('addressType must be billing or shipping') } ```



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: