I am trying to write a declaration file for the Titanium Mobile framework.
To do so i need to declare nested classes. Let me explain
In the Titanium mobile javascript environnement you have a global var Titanium
it would look like something like this:
declare module titanium {
class Proxy extends EventEmitter {}
class Module extends EventEmitter {}
class View extends Proxy {}
class TitaniumModule extends Module {
UI: UIModule
}
class UIModule extends Module {
View = View
}
export var Titanium: TitaniumModule
}
The idea is that you can do:
Titanium.UI.on('event', function() {}) ///eventEmitter
as well as
var view = new Titanium.UI.View();
The example i wrote for the declaration file does not work because of the error Initializers are not allowed in ambient contexts for all nested class declarations.
I also can't make Titanium.UI a namespace because then i cant have it extend Module and thus EventEmitter
Is there a way achieve this right now?
I saw that trick but it does not seem to work anymore.
It seems that it could be achieved if i was actually writing the objects and not just the declaration file, using static nested classes (thus the title). Could be added as a feature in a .d.ts file?
I am trying to write a declaration file for the Titanium Mobile framework.
To do so i need to declare nested classes. Let me explain
In the Titanium mobile javascript environnement you have a global var
Titaniumit would look like something like this:
The idea is that you can do:
as well as
The example i wrote for the declaration file does not work because of the error
Initializers are not allowed in ambient contextsfor all nested class declarations.I also can't make Titanium.UI a namespace because then i cant have it extend
Moduleand thusEventEmitterIs there a way achieve this right now?
I saw that trick but it does not seem to work anymore.
It seems that it could be achieved if i was actually writing the objects and not just the declaration file, using static nested classes (thus the title). Could be added as a feature in a
.d.tsfile?