paldepind / union-type

A small JavaScript library for defining and using union types.
MIT License
477 stars 28 forks source link

Parameterized type #62

Closed nsaunders closed 6 years ago

nsaunders commented 6 years ago

Let's say I've implemented a vanilla Maybe type (as in the README), a record type Properties, and another record type State that should have an optional reference to a Properties record. Is there a way to use Maybe as a parametric type, or somehow tweak it for that purpose, so that I can essentially have a Maybe Properties type?

nsaunders commented 6 years ago

This is still kind of an issue, but I essentially solved it by writing a clever validation function. I used the private validation logic in union-type.js as reference. If anyone needs some guidance on this, please let me know.