practical-fp / union-types

A Typescript library for creating discriminating union types.
MIT License
70 stars 2 forks source link

Comparison to https://github.com/twop/ts-union #1

Closed janwirth closed 2 years ago

janwirth commented 2 years ago

Why should I use this project over that one: https://github.com/twop/ts-union

felixschorer commented 2 years ago

ts-union and many other similar libraries derive types from constructor functions. That works for most cases. However, once you run into recursive or generic union types, you will have to jump through a lot of hoops.

This project derives constructor functions from types by using Proxies. That solves all those issues.

If you don't need generic or recursive unions, pick whichever you think has the nicer API / more features.

janwirth commented 2 years ago

Thanks!