Why does Angular 2 use the .ts file extension?

The .ts extension is used by TypeScript. Angular 2 does not really use the .ts extension. The code produced by the TypeScript compiler will be JavaScript with the .js extension. You can also use Dart as a development language that will still produce JavaScript code. If you feel like avoiding TypeScript or Dart, you can use plain JavaScript for developing Angular 2 applications.

With TypeScript you get some options that are not available to you in plain JavaScript. The definition of TypeScript from its web site is:

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript

To lean more about TypeScript visit its web site.


Angular 2 has the option to use multiple languages.

Languages are:

  1. JavaScript which uses .js extension (ES5 & ES6)
  2. TypeScript which uses .ts extension
  3. Dart which uses .dart extension