#Problems with a Narrowed type.

4 messages · Page 1 of 1 (latest)

versed runeBOT
#

@void fjord Here's a shortened URL of your playground link! You can remove the full link from your message.

saimon80#0

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
...```

violet plover
#

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