If you're simply wanting a constructor type, you can use this:
type Constructor<T> = new (...args: unknown[]) => T
type ABT = Constructor<AB> // new (...args: unknown[]) => AB
You can use this with instanceof
and it also allows subclasses:
const something = (Class: ABT, object: unknown) => {
if (object instanceof Class) {
object // type AB
}
}
class C extends A {}
something(C, {})
However, if the class has static members, this is not the same as typeof
:
class D {
static x = 0
}
declare const typeofD: typeof D
declare const constructorD: Constructor<D>
new typeofD()
new constructorD()
typeofD.x
constructorD.x // Property 'x' does not exist on type 'Constructor<D>'.
Playground link