How to accept a generic non-empty const string array for use in `type`?
Note: this may be a TS question, feel free to send me there instead.
I have the following type:
I'm attempting to create a function which accepts this object and returns an arktype instance of the union of the strings in the array, which is const with well-known values.
If I call it directly from the const signature, e.g.
I have tried:
This fails on the spread argument with
Unwinding the generic produces different errors:
leads to
Replacing
I suspect the two generic parameters is the closer approach, but I have no idea what this
I have the following type:
PgEnum<TValues extends [string, ...string[]]> { enumValues: TValues; }I'm attempting to create a function which accepts this object and returns an arktype instance of the union of the strings in the array, which is const with well-known values.
If I call it directly from the const signature, e.g.
type('===', obj.enumValues), it works fine. But I can't figure out how to accept this as a generic function parameter and use it in the body.I have tried:
This fails on the spread argument with
Unwinding the generic produces different errors:
leads to
A spread argument must either have a tuple type or be passed to a rest parameter.Replacing
string[] with [string, ...string[]] leads to the same issue.I suspect the two generic parameters is the closer approach, but I have no idea what this
conform<> error is, or how to begin to address it.