Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I understand that familiarity is TS' selling point, but that dreadful I-word was actually used against me when trying to introduce these unions. For whatever reason, some people don't find the syntax very natural at the moment. With no standard convention around the tag's name (it is `kind` in the linked PR, but I've seen it specified in many other ways), my suggestion came across like a cute self-invented gimmick rather than a fundamental concept in programming. Others had trouble differentiating the tag's literal type from a vanilla string due to the quotes.

If some of the noise were eventually removed and tagged unions became true first class citizens in TS' syntax, I think some of these colleagues without as much typing experience might be more open to the idea—or at the very least understand it in the first place.



> my suggestion came across like a cute self-invented gimmick rather than a fundamental concept in programming

Maybe the official handbook could help convince them this isn't the case: https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...


I love discriminated unions, but bounced off the typescript approach because it looked like too much of a pain to actually be worth it. Hopefully features like this can make it worthwhile, because I really miss them.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: