re: The Dream of C# 9.0 VIEW POST


I really wish they would bring in discriminated unions to C#. Ever since I started using them in F# I've missed them in every other language I've used.


Same here. Typescript comes close though.


Typescript doesn't come close. It goes way above and beyon with it's intersection, union, mapped and conditional types. I worked on a project where I was in charge of frontend (ts) and my coworker was doing backend (.net) and we wanted to move some logic from client to server. And it just wasn't possible to write without using dynamic which throws all compile time checks out of the window.

While I agree that the TS type system is awesome, discriminated unions in TS are a bit clunky, compared to Haskell/F#. Would be good to see them become a first class concept in TS, and not a side-effect of the super flow analysis.

code of conduct - report abuse