4

I have been trying to get this thing to work for quite a while now, and so far no solution that I have found has worked for me.

This is what I have:

//Test.ts
module t
{
    export class Test
    {
        constructor ()
        {
            alert("test");
        }
    }
}

//Main.ts
/// <reference path="Test.ts" />

var test: t.Test = new t.Test();

As you can see I have two files, one is Main.ts and the other one is Test.ts. They are both in the same folder. Also if it helps I am using VS2012 and the Typescript plugin.

Thank you for the help! EDIT: Oh btw, I get the error (in chrome): Uncaught ReferenceError: t is not defined

1 Answer 1

6

You need to include both scripts in your web page:

<script src="test.js"></script>
<script stc="main.js"></script>
Sign up to request clarification or add additional context in comments.

3 Comments

Be sure that you put "test.js" before "main.js", otherwise you'll end up with the same error. I lost a girlfriend, a computer and my sanity because of not doing that (threw them all out in anger).
In the original question, it is main.ts that relies on test.ts - so they have to be this way around. You probably assumed that test.ts was testing main.ts, but that isn't the case in this question. I don't want you to lose another computer over this :)
Oh right. Fortunately I had the explained problem on another code base and just mixed it up here ;).

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.