Did I do something wrong, or is it a bug? (TypeScript / Visual Studio 2012)

advertisements

Resolved:

Thank you all for your help. I'm not sure exactly what caused this, but I restarted Visual Studio and everything went back to normal. Not sure why, but it's been working ever since (yesterday).


I didn't have these problems last night (with the same code - unchanged):

I don't see what the issue is.

The error I am getting is:

JavaScript critical error at line 1, column 9 in [path/app.ts] SCRIPT1004: Expected ';'.

What the deuce?!

Incase you can't see the image, the error is referring to this line: declare var document;

Update

The javascript file which is a result of the TypeScript being compiled into JavaScript looks like this:

window.onload = function () {
    start();
};
function sayHello(msg) {
    return msg = "Hello, therel ol!";
}
function start() {
    var element = document.getElementById("link");
    element.addEventListener("click", function () {
        var element = document.getElementById("response").innerText = sayHello("Hi");
    }, false);
    if(XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    } else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
}

And as you can see, everything looks fine. I don't get why it's throwing this error.


My guess is that you have referenced the app.ts file on your page by mistake, when you should have referenced the app.js file.

I'm assuming you get this error when running your application, not at design time.

i.e.

<script src="app.ts"></script>

Should be

<script src="app.js"></script>