You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 8, 2021. It is now read-only.
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:
TypeScript is the recommended language to use for Angular 2. See https://angular.io/ which defaults to TypeScript examples (unless you request otherwise)
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
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.
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.
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.