Can someone help me understand how to tell TypeScript that a function returns instances of a specified class?
class A extends HTMLElement {
color: 'white'
}
function builder<T extends typeof HTMLElement>(classParam: T) {
let instance = new classParam()
return instance
}
let instance = builder(A)
instance.color = 'black'
// Property 'color' does not exist on type 'HTMLElement'
Is there a way to achieve this without using type assertion?