Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

TypeScript Guidelines

Tim Donohue edited this page Mar 31, 2016 · 2 revisions

Why did we choose TypeScript?

When building an Angular 2 application, you have a choice of using TypeScript, Javascript or Dart. Here's why we chose TypeScript:

  1. TypeScript is the recommended language to use for Angular 2. See https://angular.io/ which defaults to TypeScript examples (unless you request otherwise)
  2. Angular 2 is itself written in TypeScript. One of the Angular 2 developers describes why they made that decision is in post Writing Angular 2 in TypeScript
  3. TypeScript is gaining a strong following. It was written by Microsoft. But, Google is now recommending it and using it over their own competitor Dart. More info: https://jaxenter.com/angular-typescript-dart-115426.html
  4. TypeScript is a superset of Javascript itself and can be compiled into clean Javascript code. This means that if it should ever go away, we could migrate easily to Javascript. See http://www.typescriptlang.org/ for more.
  5. TypeScript supports the latest features of Javascript (again see http://www.typescriptlang.org/)
  6. Code in TypeScript is more similar to Java (i.e. DSpace backend) than it would be if we used Javascript or Dart. It also make more easily readable code than Javascript.

Other references on this question:

How do we recommend writing TypeScript code for this app?

  • Because TypeScript is a superset of Javascript, you could simply write Javascript and save it into a file with a .ts extension (because any valid Javascript is also valid TypeScript). We recommend AGAINST writing Javascript code in TypeScript files!
    • Why? If you write Javascript in your TypeScript files you are bypassing the distinct advantages of TypeScript, namely using Types and Type Definitions. You also may be working against many TypeScript IDE tools, and potentially writing more complex code overall.