3 ms·
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 getTable
by chipsrafferty 2y ago
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')
}
```