Typescript 如何在变量中获取类的内容

Typescript 如何在变量中获取类的内容,typescript,Typescript,我有一个管理器,负责保存PIXI.Container的场景,它可以通过变量this.Scene访问场景的内容 所以我可以去做这个例子。_scene.update() 虽然我不确定如何使系统能够动态检测场景的内容(哪个场景可以有多个名称,但它们都是scene\u Base的孩子,他们使用相同的方法) 所以我的第一个方法是: interface ISceneConstructor { new(): Scene.Base; } 然后将其分配给private static\u场景:IScen

我有一个管理器,负责保存
PIXI.Container
的场景,它可以通过变量this.Scene访问场景的内容 所以我可以去做这个例子。_scene.update()

虽然我不确定如何使系统能够动态检测场景的内容(哪个场景可以有多个名称,但它们都是
scene\u Base
的孩子,他们使用相同的方法)

所以我的第一个方法是:

interface  ISceneConstructor {
    new(): Scene.Base;
}
然后将其分配给
private static\u场景:ISceneConstructor=null

虽然当我这样做的时候:

this._scene.methodName();
据说它可以在
ISceneConstructor
上找到方法名,而它应该引用类Scene\u Base或传递给
\u sceneVariable
的任何场景。 它不是由new直接调用的,由另一个变量引用,该变量是:

this._nextScene = new sceneClass(); <-- wich is a type of ISceneConstructor
SceneManager.changeScene = function() {
    if (this.isSceneChanging() && !this.isCurrentSceneBusy()) {
        if (this._scene) {
            this._scene.terminate();
            this._scene.detachReservation();
            this._previousClass = this._scene.constructor;
        }
        this._scene = this._nextScene; // <-- where you see the assignation.
        if (this._scene) {
            this._scene.attachReservation();
            this._scene.create();
            this._nextScene = null;
            this._sceneStarted = false;
            this.onSceneCreate();
        }
        if (this._exiting) {
            this.terminate();
        }
    }
};
this.\u nextScene=new sceneClass();