There is a fact that writing application in JavaScript is so hard. JavaScript is not a programming language and this makes it so hard to manipulate it especially in large application and JavaScript is never designed for large application development. Typescript is a language for application-scale JavaScript development, free and open source programming language by Microsoft which compiles to plain JavaScript. Typescript is entirely dynamically typed and every JavaScript code is a valid typescript code and you can copy and Paste JavaScript code to typescript. Typescript supports tools for large-scale JavaScript applications for any browser, for any host on any OS.
As you can see in the example below (created by the visual studio), Typescript adds optional types, classes, and modules to JavaScript. and essentially adds optional static typing and class-based object-oriented programming.
// Interface interface IPoint { getDist(): number; } // Module module Shapes { // Class export class Point implements IPoint { // Constructor constructor (public x: number, public y: number) { } // Instance member getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } // Static member static origin = new Point(0, 0); } } // Local variables var p: IPoint = new Shapes.Point(3, 4); var dist = p.getDist();
Typescript extends JavaScript syntax, so any existing JavaScript programs work with Typescript without any changes. Typescript is designed for development of large applications and when translated it produces JavaScript to ensure compatibility.
Category: Software
Tags: TypeScript