According to Typescript documentation, the correct type for specifying a class constructor is the following:
type Class = { new (...args: any[]): {} }
And if you try to index this type like this:
type ClassPrototype = { new (...args: any[]): {} }["prototype"]
// OR EVEN
type ClassPrototype = Class["prototype"]
Everything is fine with the compiler while if you try something like the following, an error occurs:
type PrototypeOf<T extends { new (...args: any[]): {} }> = T["prototype"] // <-- Type '"prototype"' cannot be used to index type 'T'.
And I am not sure why this happens. If I am able to index Class with Class["prototype"] why am I not when it is a generic <T extends Class> with T["prototype"]? The solution i have found temporarily is changing <T extends Class> with <T extends { prototype }> but it doesn't look clean.
I have included the context I want to use this in here: playground link