samedi 29 novembre 2014

Typescript equivalent to JS Module pattern


I'm using the JS Module pattern (as described in this post), and I have code that looks like this:



Foo = (function($, ko) {

//Constructor for Foo
var Foo = function () {
//Uses $ and ko
};
return Foo;

})($, ko)


I want to convert this pattern to a TypeScript equivalent, but I'm not sure what that would be. Do I replace the whole IIFE with this?



class Foo {
constructor() {
//Uses $ and ko
}
}


That seems roughly equivalent, but then it loses the explicit injection of my dependencies. Is this the way to do this in TypeScript?





Aucun commentaire:

Enregistrer un commentaire