Type Alias Class<T>

Class: new (...args: any[]) => T

Generic type for class.

Type Parameters

  • T
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