Type alias Class<T>

Class<T>: (new (...args) => T)

Generic type for class.

Type Parameters

  • T

Type declaration

    • new (...args): T
    • Parameters

      • Rest ...args: any[]

      Returns T

Example

interface A {
a: number
}
class B implements A {
a = 1
}

// Store class in variable
const c: Class<A> = B
console.log(typeof c === Class<B>) // true

// Passing class to function
function f(p: Class<A>) {
console.log(p)
}
f(B) // ok