Is there any sample of using TypeScript with KnockoutJS? I'm just curious as to how they would work together?
Here is what I have, seems to work
declare var ko: any;
declare var $: any;
class ViewModel {
x = ko.observable(10);
y = ko.observable(10);
}
$(() => {
ko.applyBindings(new ViewModel());
});
This generates into the following Javascript:
var ViewModel = (function () {
function ViewModel() {
this.x = ko.observable(10);
this.y = ko.observable(10);
}
return ViewModel;
})();
$(function () {
ko.applyBindings(new ViewModel());
});
Look at DefinitelyTyped.
"TypeScript type definitions repository for popular JavaScript libraries"