Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
31. module graphic
{
export class Point
{
x: number;
y: number;
constructor( x: number = 0, y: number = 0 )
{
};
}
}
var point = new graphic.Point( 10, 10 );
37. class Shape { ... }
class Circle extends Shape { ... }
function createShape( kind: string ): Shape {
if ( kind === "circle" ) return new Circle(); ...
}
var circle = <Circle> createShape( "circle" );