The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
#Problems with a Narrowed type.
4 messages · Page 1 of 1 (latest)
@void fjord Here's a shortened URL of your playground link! You can remove the full link from your message.
Preview:```ts
const SIDE_NAV_EXPANDED_COOKIE_NAME = side_bar_open
const ROWS_PER_PAGE_COOKIE_NAME = rows_per_page
const TABLE_ROWS_PER_PAGE_OPTIONS = [
1, 2, 3, 10, 25, 50,
]
const userPreferences = {
rowsPerPage: ROWS_PER_PAGE_COOKIE_NAME,
sideNavExpanded: SIDE_NAV_EXPANDED_COOKIE_NAME
...```
You can choose specific lines to embed by selecting them before copying the link.
so acc[keyValue] doesn't know which branch it's in, so something assigning onto acc[keyValue] would need to work for both branches, which doesn't work since number and boolean don't overlap (giving never)
you could narrow into each branch, but that's not really feasible for larger objects i suppose