The parameter problem when the typescript parameter is a class

I have defined an abstract class
I have multiple subclasses to implement abstract methods of abstract classes

export abstract class Base {
    doSomeThing() {

    }
    abstract beforeDo():void;
}
class work extends Base {
    beforeDo() {
        console.log("work")
    }
}
class study extends Base {
    beforeDo() {
        console.log("study")
    }    
}
function dd(doo: Base) {
    new doo();
}

but I have to report an error when I go to new like this. Please tell me how to deal with this problem-sharp-sharp-sharp topic description

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Nov.08,2021

Abstract classes cannot be instantiated, you can do so

export class Base {
    doSomeThing() {

    }
    beforeDo(){throw new Error('error')}
}

also, your parameter declaration type is wrong. It should be typeof Base

.
function dd<T extends Base> (doo: { new(): T }) {
  const x = new doo()
}

it is estimated that what you want is this

Menu