Reviewing the code snippet:
const events = {
a: ['event1' as const, 'event2' as const],
b: ['event3' as const, 'event4' as const],
};
class SomeClass<
T extends AnotherClass<typeof events[keyof typeof events][number]>
> {}
T
will be:
T in SomeClass<T extends AnotherClass<"event1" | "event2" | "event3" | "event4">>
However, I want to achieve:
T in SomeClass<T extends AnotherClass<"event1" | "event2"> | AnotherClass<"event3" | "event4">>
Is there a more efficient way to get this result without explicitly listing all options like so:
class SomeClass<
T extends
| AnotherClass<typeof events.a[number]>
| AnotherClass<typeof events.b[number]>
> {}