I am trying to export a class that is defined within a function. So, I tried declaring a class export like this:
export declare class GameCameraComponent extends GameObject {
isMainCamera: boolean;
}
export abstract class GameObject<T extends { new(...args: any[]): any; } = any> { }
// Used for my decorator
export function Camera(options?: CameraOptions) {
return function (target: new () => object) {
return class GameCameraComponent extends GameObject {
instance = new target();
readonly isMainCamera; // Set in the constructor
}
}
}
No errors are created everything seems fine. Now I want to check somewhere else if the item is an instance of that exported definition like this:
export class CameraService {
constructor() {
const cam = Engine.gameObjects.find(o => o instanceof GameCameraComponent && o.isMainCamera);
}
}
Now at this point, I get the two following errors (I believe this is from webpack as there are no errors in the vscode editor):
export 'GameCameraComponent' (imported as 'GameCameraComponent') was not found in '../decorators' (possible exports: Camera, GameObject, ObjectChild, ObjectChildren, Path, Prefab)
Next, in the chrome console I get this error:
Uncaught TypeError: Right-hand side of 'instanceof' is not an object
How can I see if the item is an instanceof the inner function class?