Below is the simplified code snippet that I am working with:
class Component {
}
class CameraComponent extends Component {
foo: number;
constructor(bar: number) {
super()
}
}
function doSomething(klass: typeof Component) {
}
doSomething(CameraComponent);
Encountering the error message:
TS2345: Argument of type 'typeof CameraComponent' is not assignable to parameter of type 'typeof Component'.
To resolve this error, I made a modification to CameraComponent
as shown below:
class CameraComponent extends Component {
foo: number;
constructor() {
super()
}
}
I'm curious about why changing the constructor signature fixed the issue. Is there any other way to address this problem without using any
?