I've got some generic type
export interface Generic<T>{...}
I want to use it as the type for some other generic e.g.
let generics: Array<Generic> = [];
Obviously that doesn't work as I haven't specified its own type. Is there a way for me to create a union type which encapsulates all possible types for T? (So I can then do let generics: Array<Union>
)
For example, if my program happens to provide string, number, ClassA and InterfaceB as possibilities for T, this union type would be string | number | ClassA | InterfaceB
. But I can't know/declare those upfront (which would defeat the purpose of the generic anyway)
I've tried various approaches but the "compiler" is never happy.