Handling `unknown` in TypeScript… isn't it painful?
Hi there 👋 I'm a frontend engineer based in the Netherlands, currently suffering from hay fever...
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 1436158) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } nyaomaru Posted on Apr 28 Handling `unknown` in TypeScript… isn't it painful? #webdev #programming #opensource #typescript Hi there 👋 I'm a frontend engineer based in the Netherlands, currently suffering from hay fever 😿 API responses, form inputs, external data… In TypeScript, we often end up dealing with unknown, and handling it properly can become a real pain in day-to-day work. Yes, unknown has a kind of gravitational pull like the universe.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV Community.