[Q in `${Prefix}${string & K}`]?: XOR<
[arraySize, elemMatch<U>, DeepPartial<U | U[]>, ComparisonOperators<U>]
>;
I have this XOR utility which lets you choose only of the given types and I got it generated through claude. When i pass 4 or more arguments to this utility type the typescript seems to give up and complains "Expression produces a union type that is too complex to represent." why is this behaving this way and how can i resolve this ?
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
export type XOR<T extends any[]> = Prettify<
T extends [infer Only]
? Only
: T extends [infer First, ...infer Rest]
?
| (Without<First, XOR<Rest>> & XOR<Rest>)
| (Without<XOR<Rest>, First> & First)
: never
>;