Imagine a scenario where a class has multiple type parameters:
class BaseClass<T extends T1, U extends U1, V extends V1, /* etc. */ >
Is there a method to consolidate these type arguments in a way that allows for "spreading" or "destructuring," similar to what ES6 offers for objects?
Instead of having to create subclasses like:
class FooClass extends BaseClass<TFoo, UFoo, VFoo, /* etc. */ >
Is it possible to set all type arguments at once like this:
// example of the desired functionality:
metatype FooTypes = <TFoo, UFoo, VFoo, /* etc. */>
class FooClass extends BaseClass<...FooTypes>
The purpose behind exploring this idea is that I have various objects managing different attributes of entities such as "notes" and "comments," each with multiple associated types. However, not all objects interacting with them need to handle every type.
My goal is to provide a single reference like "NoteTypes" or "CommentTypes" that essentially says "You can use any necessary type parameters from this pool."
While "type destructuring" seems like the ideal solution, the lack of support for it in TypeScript, as mentioned in this GitHub issue, poses a challenge.
In the absence of type destructuring, what would be the most effective approach to tackle this issue?