Compile-time typesafe merge/and for data-only "traits"
I've evaluating introducing arktype to a typescript codebase, but I got stuck trying to use it to set up my POJO "traits" system. This is similar in concept to the Trait abstract class in
So I have a discriminated union that represents the different "traits" and the union members share a common shape (mainly references to other trait names), something along these lines:
I'm confused about how I would represent this setup in arktype in a typesafe manner? Or would you suggest an alternative way of representing this? I don't have any significant code written against these types so I'm open to rethinking this setup entirely.
I got stuck almost immediately as neither
Please help! Thanks
arktype/util but this is data only; so far I've avoided the need to introduce any classes and I'm hoping to maintain this approach.So I have a discriminated union that represents the different "traits" and the union members share a common shape (mainly references to other trait names), something along these lines:
I'm confused about how I would represent this setup in arktype in a typesafe manner? Or would you suggest an alternative way of representing this? I don't have any significant code written against these types so I'm open to rethinking this setup entirely.
I got stuck almost immediately as neither
.and(...) nor.merge(...) will allow me to inherit compile-time type checking of requires in my Trait subtypes.Please help! Thanks
