Generic minimum and maximum
Is it possible to create a type that is generic over a min/max value?
I wanted something like this:
but clearly this is the wrong way of thinking about it because min and max are only supported as constants.
I've read through the docs on scope and generics and I feel like the solution is in there somewhere but I can't quite work it out. My use case is that I have an object type that's a union so it can be structured differently but numbers inside of it all share the same min/max values. Currently I have to redefine the entire object's structure to set a min/max value as it's not always the same min/max values.
I wanted something like this:
but clearly this is the wrong way of thinking about it because min and max are only supported as constants.
I've read through the docs on scope and generics and I feel like the solution is in there somewhere but I can't quite work it out. My use case is that I have an object type that's a union so it can be structured differently but numbers inside of it all share the same min/max values. Currently I have to redefine the entire object's structure to set a min/max value as it's not always the same min/max values.