You can use class expressions for this (as of 1.6 I believe).
var x = new (class {
/* ... lots of singleton logic ... */
public someMethod() { ... }
})();
or with the name if your class needs to access its type internally
var x = new (class Singleton {
/* ... lots of singleton logic ... */
public someMethod(): Singleton { ... }
})();
Another option is to use a local class inside of your singleton using some static members
class Singleton {
private static _instance;
public static get instance() {
class InternalSingleton {
someMethod() { }
//more singleton logic
}
if(!Singleton._instance) {
Singleton._instance = new InternalSingleton();
}
return <InternalSingleton>Singleton._instance;
}
}
var x = Singleton.instance;
x.someMethod();