javascript - Accessing global method with namespace in TypeScript -
i'm trying call method in .js file looks this:
if (typeof shared === "undefined" || !shared) { var shared = {}; } shared.helperclass = (function () { // ... private stuff here return { init: function() { }, testmethod: function(name) { return name; } }; })();
naturally call init in javascript, i'd call:
shared.helperclass.init();
now have typescript file i'd call in, throws compiler error because doesn't know is.
how tell typescript these methods such can call code .ts file?
how tell typescript these methods such can call code .ts file?
create file globals.d.ts
, add following
declare var shared:any;
done!
more
more on migrating : https://basarat.gitbooks.io/typescript/docs/types/migrating.html
Comments
Post a Comment