The complete guide to safe type narrowing in TypeScript

from blog Vladimir Klepov as a Coder, | ↗ original
Say I'm building a TODO app with two tabs: done and pending tasks. To make the app routable, I put the active tab into the ?tab query parameter, so that mytodo.io?tab=done takes me directly to the done tasks. I implement routing like this (pardon my hand-coded querystring parser): const tasks = { done: [], pending: [],};const tab =...