Sweetjs is unfortunately dead [0] for like 5 years now.
It also doesn't have any typescript awareness which is required to build this kind of functionality - you want to have static type introspection available in macros so you can generate code based on provided types.
Comments
To be honest it doesn't even have to do anything during runtime per se.
It just needs to have nice macro system.
It would solve this problem and others like ie. pattern matching.
there's always https://www.sweetjs.org/ that you can plug into your Babel pipeline
Sweetjs is unfortunately dead [0] for like 5 years now.
It also doesn't have any typescript awareness which is required to build this kind of functionality - you want to have static type introspection available in macros so you can generate code based on provided types.
[0] https://github.com/sweet-js/sweet-core/graphs/contributors