Comment

Comment by wk_end

You don't need a library for this; the idiomatic approach is to lean on TypeScript's narrowing and native control flow (ifs and switches, or maybe IIFEs), along with (maybe) the never type to enforce exhaustiveness.

https://www.typescriptlang.org/play/?jsx=4#code/JYWwDg9gTgLg...

I guess the library is slightly nicer, arguably, but I don't think it's worth the external dependency and added complexity.

parent wk_end 13 days ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton