export class Entity { add(component: Component, componentClass?: { new (): Component;}): Entity { if (!componentClass) { componentClass = component.constructor } } }
Line 4 of the example (assignment of the .constructor component) makes the compiler complain that:
The constructor property does not exist with a value of type Component
What is the correct way to get a reference to an object constructor? I understand that all objects in JavaScript have a .constructor property that points to the constructor used to create this object ...
source share