TypeScript

With powerful JavaScript frameworks on the rise, developers are able to build a wide range of applications. From short event handler implementations to large scale application development. JavaScript engines have gained widespread popularity among programmers. Along with JavaScripts new capabilities, large scale developers were experiencing a common issue.  Considering that JavaScript is a dynamically typed language, there is simply no large scale structuring concepts. This means that the language lacks the necessary capabilities to build intelligent tooling such as code completion, safe refactoring, etc.

In 2012, Microsoft had publicly released TypeScript, an open source super-set of JavaScript which compiles to plain JavaScript. TypeScript was designed to strengthen JavaScript’s core concepts of open standards and cross platform compatibility. By implementing optional static typing, classes and modules, developers are able to build great tooling to power today’s IDE’s such as Microsoft’s Visual Code.

The TypeScript compiler produces pure JavaScript code which in turn eliminates the need for a run-time component. This allows TypeScript to be implemented in any browser as well as any JavaScript engine that supports ES3 or higher. (AngularJs, NodeJs, etc.)

TypeScript

class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return “Hello, ” + this.greeting;
}
}

JavaScript

var Greeter = /** @class */ (function () {
function Greeter(message) {
this.greeting = message;
}
Greeter.prototype.greet = function () {
return “Hello, ” + this.greeting;
};
return Greeter;
}());

TypeScript Features
  • Type annotations and compile-time type checking
  • Type inference
  • Type erasure
  • Interfaces
  • Enumerated type
  • Mixin
  • Generic
  • Namespaces
  • Tuple
  • Await

Experiment with Typescript’s and it’s features in a virtual playground.

Playground · TypeScript

Try TypeScript in your browser!

Leave a Reply

Categories

Follow me on Twitter