DenoDDeno
Powered by
1771771771
Denoβ€’4y agoβ€’
3 replies
177177177

extract generic type of generic class

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
ExtendedClient
be the same as the generic type of
Client
Client
. but i dont have access to generic type of
Client
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> {}
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Inconsistent type checking of overloaded generic functions on publish
MaikMMaik / help
8mo ago
Check if class instance is instance of provided type
KayKKay / help
2y ago
WASM / Extract and manipulate Array of Date
foobarFfoobar / help
3y ago
type error of express
vinit_parekhVvinit_parekh / help
16mo ago