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

It is decided:

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


I did not have these problems last night (with the same code - no change):

enter image description here

I do not understand what the problem is.

The error I get is:

Critical JavaScript error on row 1, column 9 in [path / app.ts] SCRIPT1004: The expected ';'.

What a deuce ?!

If you do not see the image, the error refers to this line: declare var document;

Update

The javascript file that is the result of compiling TypeScript into JavaScript is as follows:

 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 good. I do not understand why this is throwing this error.

+7
source share
2 answers

I assume that you referenced the app.ts file on your page by mistake when you should link to the app.js file.

I assume that you will get this error when starting the application, and not during development.

i.e.

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

Must be

 <script src="app.js"></script> 
+11
source

You do not need to declare the document - it must already be declared. It comes from the virtual lib.d.ts file, which is referenced by default.

Try commenting on the ad line.

+2
source

All Articles