I'd like to get the type of a TypeScript class constructor function. In my simple attempts it is always generic Function and not the actual constructor with the parameters as I'd expect.
class BufferedController {
constructor(id: number) {
this.id = id
}
static defaultBufferSize = 100 as const
id: number
}
// ?? Just generic Function not the actual constructor
type instanceConstructor = BufferedController["constructor"]
// Class type
type C = typeof BufferedController
// This works fine to get other static properties from the class
type n = C["defaultBufferSize"]
// ?? Also generic Function not the actual constructor
type c = C["constructor"]
What is the correct way to get the type of the constructor function from the class? I'd like to end up with a type like constructor(id: number) => BufferedController