Incorrect converting from TypeScript to Javascript

Topics: Code Checkins
Oct 27, 2012 at 8:59 PM
Edited Oct 27, 2012 at 9:34 PM
// invalid TypeScript code (forgotten curly bracket)
function greeter(person) {
    return "Hello, " + person;
// } missing

var user = "Jane User";

document.body.innerHTML = greeter(user);

----------------------------------------------------

// incorrect JavaScript result
function greeter(person) {
    return "Hello, " + person;
    var user = "Jane User";
    document.body.innerHTML = greeter(user);
}
Nov 5, 2012 at 4:18 PM

The compiler detects that there's an error and gives you a warning.

It can't read your mind though.

Nov 5, 2012 at 5:00 PM

???
I did not write about mind-reading :)
Please try it on the  playground:
http://www.typescriptlang.org/Playground/

There is still no error message.
But there is still an incorrect JavaScript code.

Nov 6, 2012 at 12:37 PM

Even though TypeScript auto-completes when you add the first curly brace.

There will be a time when you have looked at the same code for so long that if you don't get an error message for accidentally deleting a curly brace. You could be spending a while in trying to debug it.