0

I'm trying to call a method in another .js file that looks like this:

if (typeof Shared === "undefined" || !Shared) {
    var Shared = {};
}

Shared.HelperClass = (function ()
{
    // ... private stuff here

    return {
        Init: function()
        {

        },

        TestMethod: function(name)
        {
            return name;
        }
    };

})();

Naturally to call init in Javascript, i'd call:

Shared.HelperClass.Init();

Now I have a TypeScript file i'd like to call this in, but it throws a compiler error because it doesn't know what it is.

How do I tell TypeScript about these methods such that I can call this code from my .ts file?

1 Answer 1

1

How do I tell TypeScript about these methods such that I can call this code from my .ts file?

Create a file globals.d.ts and add the following

declare var Shared:any;

Done!

More

More on migrating : https://basarat.gitbooks.io/typescript/docs/types/migrating.html

Sign up to request clarification or add additional context in comments.

1 Comment

I guess I was making it way too hard on myself. Thanks! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.