WeSearch

Handling `unknown` in TypeScript… isn't it painful?

·4 min read · 0 reactions · 0 comments · 2 views
Handling `unknown` in TypeScript… isn't it painful?

Hi there 👋 I'm a frontend engineer based in the Netherlands, currently suffering from hay fever...

Original article
DEV Community
Read full at DEV Community →
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.

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from DEV Community