Prashobh
Prashobh

Reputation: 9544

Angular 2 + typescript or Angular 2 + Javascript which one is advisable

I have better knowledge in Angular and I have been working on almost 3 years in Angular. I just started learning Angular 2 and bit confused. I should learn Angular 2 + Typescript or I can go with Angular + JavaScript ES6. All the documentation available on internet is Angular + typescript . Which one is better for future?

Upvotes: 1

Views: 129

Answers (3)

Tiberiu Popescu
Tiberiu Popescu

Reputation: 4524

  • Angular2 is written in Typescript and the team recommends to use it
    with Typescript.
  • Here on stackoverflow over 90% of questions/answers are submitted in Typescript.
  • At this moment angular2 docs has a better support in typescript (this may change until the official release)

So yeah, I think that Angular2 will be more popular in Typescript than ES6/ES5/Dart, I will definitely advise to use it with Typescript.

Upvotes: 2

Thierry Templier
Thierry Templier

Reputation: 202346

The main differences between ES6 and TypeScript in the context of Angular2 applications are the following:

  • You can't use types for class properties, variables and method parameters.

  • Decorators for method parameters aren't supported. For example for dependency injection, you need to specify a static setter for the "parameters" property:

    constructor(http) {
      this.http = http;
    }
    
    static get properties() {
      return [[ Http ]];
    }
    

    With TypeScript, you will have this:

    constructor(private http:Http) {
    }
    

So both are usable in Angular2. The framework promotes more TypeScript in docs but Ionic2 (that uses Angular2) uses by default ES6 in the application created using "ionic start". So you're free to use one or the other.

The main advantage of TypeScript is its "strong typing" feature that allows you to ensure that the right structures are provided / returned and you don't use something that isn't present on objects.

Another cool thing is the support of IDEs for autocompletion when developping TypeScript applications.

Upvotes: 4

Fka
Fka

Reputation: 6244

Based on my experience, I'd recommend you learn Angular + JavaScript ES6, because Angular 2 is still under beta. A lot of things will change during your learning so you'll have to learn same things over and over. Documentation or tutorials will be also obsolete.

Upvotes: 0

Related Questions