D
Deno

help

extract generic type of generic class

R!Roricchi 2.0『藤田の妻』10/6/2022
how to get typeof generic type in generic class
class GenericClass<T> {}
class GenericClass<T> {}
i want to extract type T i am using a library, it exports a generic class, but doesnt export the generic type that the generic class takes, and i want to extend the generic class, like this
export class MyGenericClass<T extends GenericClassTypeArgument<GenericClass>> extends GenericClass<T> {}
export class MyGenericClass<T extends GenericClassTypeArgument<GenericClass>> extends GenericClass<T> {}
another example,
class ExtendedClient<T> extends Client<T> {}
class ExtendedClient<T> extends Client<T> {}
i want the generic type of ExtendedClient be the same as the generic type of Client. but i dont have access to generic type of Client, so thats why i want to extract it. so i can do
class ExtendedClient<T extends GenericTypeOf<Client>> extends Client<T> {}
class ExtendedClient<T extends GenericTypeOf<Client>> extends Client<T> {}
the library im using is made by some dumb, they export Client but not ClientStates so i cant use ClientStates thats why i want to extract it from Client like the Utility type Parameters to extract the type of arguments of a function
UUUnknown User10/6/2022
Message Not Public
Sign In & Join Server To View
R!Roricchi 2.0『藤田の妻』10/7/2022
ty!

Looking for more? Join the community!