5 ms·
As you've demonstrated, you can always construct sum types in typescript with the use of explicit discriminants: T = {tag: "L", payload: L} | {tag: "R", pa
by akavi 2y ago
As you've demonstrated, you can always construct sum types in typescript with the use of explicit discriminants:
T = {tag: "L", payload: L} | {tag: "R", payload: R}
The real issue is typescript doesn't have pattern-matching, which make operating on these sum types inelegant