We have a fair amount of javascript that we would like to start bringing into the TypeScript world. Ideally, we would be able to create TypeScript declaration files without having to alter existing javascript code.
Below is a tiny snippet of code from Microsoft's Ajax Timer that is very much in line with the type of code that we would like to create declaration files for.
I've spent several hours trying to create a declaration file that makes TypeScript happy, but it really hasn't worked out well to this point.
How would a declaration file for the following code look?
Type.registerNamespace("Nmspc");
Nmspc.Timer = function () {
Nmspc.Timer.initializeBase(this);
this._interval = 1000;
this._enabled = false;
this._timer = null;
};
Nmspc.Timer.prototype = {
get_interval: function() {
return this._interval;
},
set_interval: function(value) {
if (this._interval !== value) {
// snip
}
},
get_enabled: function() {
return this._enabled;
},
};