Assuming you understand that your code is equivalent to:
var a, b
b = a + 10
a = 10
alert(b.toString())
Which in turn is equivalent to:
var a = undefined, b = undefined
b = a + 10
a = 10
alert(b.toString())
The reason why it should be allowed is because undefined is a valid value for a variable that you can assign and read.
There are various use cases where this functionality is valuable. E.g The module pattern used in typescript:
module x{
export var foo;
}
Generates javascript code that exploits this fact:
var x;
(function (x) {
x.foo;
})(x || (x = {})); //x was never assigned but used in "x ||" part
This is left in TypeScript due to JavaScript backward compatibility (not to mention it is useful).
Here is a purely TypeScript usecase. Perhaps you want to pass undefined into a function call (this is valid typescript):
var a:number = undefined; // same as simply "var a"
console.log(a);
It is just assumed that the TypeScript developer wants the power of the underlying JavaScript language.
This is not the case for languages where Reading before Assignment is invalid (e.g C#). In C# an unassigned variable has no meaning. In JavaScript it does. So TypeScript has to allow this.