"Let's go back,
back to the beginning"
—Hilary Duff
"[The designer] reads up on
every mistake ever made in designing a programming language ,
invents a few more,
and creates [JavaScript]."
— James Iry
But why?
So, what's their problem?
JavaScript
function repeat(s) {
return s + s;
}
function square(x) {
return x * x;
}
TypeScript
function repeat(s: string) : string {
return s + s;
}
function square(x: number) : number {
return x * x;
}
JavaScript
var foo = (function() {
return {
Bar: ...
};
})();
TypeScript
module foo {
export class Bar {
// ...
}
}
JavaScript
var Greeter = (function () {
function Greeter(message) {
this.greeting = message;
}
Greeter.prototype.greet = function () {
return "Hello, " + this.greeting;
};
return Greeter;
})();
TypeScript
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
JavaScript
function(x, y, z) {
return [x, y, z];
}
TypeScript
(x, y, z) => [x, y, z]
TypeScript ⊋ JavaScript
(Obtuse way to say TS is a strict superset of JS.)
So, existing JS is automatically valid TS.
Signs point to yes.
A small, modular, type-friendly superset of JavaScript.
As applications grow, JavaScript quickly becomes unwieldy.
http://www.typescriptlang.org/Playground/
It's already available, including support for Node and Visual Studio.
Everywhere; especially in large-scale applications.