meteor - TypeScript Javascript patterns -


i busy creating meteor.d.ts support typescript developments on meteor.js platform. current status can found here

with said, having issues abstracting 2 typical javascript patterns.

the first 1 template.mytemplate.events(eventmap), mytemplate can dynamically created user.

second, ability map this different interface. meteor uses pattern lot. instance, when calling meteor.methods(..methods..), methods given access this.issimulation() not visible anywhere else.

kind of difficult explain, @ meteor documentation may help

any idea how declare these 2 patterns?

thank you.

mytemplate solution provide 2 interfaces user. 1 can use add new templates template. allow him specify features of template:

interface itemplate{  } interface itemplatestatic{     events:function; }  declare var template:itemplate;   // user's code:  interface itemplate{     mytemplate:itemplatestatic;  } template.mytemplate.events({});  

this solution answer second question this. way expose signatures interface. responsibility of typescript user proper type if needs it. there no way implicity specify type of this inside function.

declare module meteor{     interface imethod{         // simple sample          issimulation:boolean;      } }  declare var meteor;  // user experience meteor.methods({   foo: function (arg1, arg2) {     var item:meteor.imethod = this;       console.log(item.issimulation); // signature enforced     return "some return value";   } }); 

ofcourse leave naming convention :)


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo