My previous answer omitted the static getter.
This is how the ES6 constructor should actually be written:

export class MyComponent {
  fooService;
  static get parameters() { return [[FooService]]; }
  constructor(fooService) { this.fooService = fooService; }
}

I have been writing my component classes this way, and they work fine with 
Angular CLI.
I will update this thread if I encounter any errors transpiling 
ES6-with-decorators with ts-node, or compiling it AOT

D

On Friday, June 23, 2017 at 12:15:18 PM UTC-5, D Mellstrom wrote:
>
> You must also add "es6" to "lib" array in tsconfig.json, or pass "--lib 
> es6" to the compiler, to enable the use of all ES6 features such as 
> Array.prototype.find()
>
> On Friday, June 23, 2017 at 12:52:22 AM UTC-5, D Mellstrom wrote:
>>
>> Most ES6 with decorators should compile fine with the TypeScript 
>> compiler, as TypeScript aims to be a superset of ES. The main caveat I have 
>> found is that you have to declare a class member if you want to assign it 
>> in the constructor in an ES6-like way.
>>
>> So this ES6 won't compile:
>>
>> export class MyComponent {
>>   constructor(fooService: FooService) { this.fooService = fooService; }
>> }
>>
>> But this ES6 will:
>> export class MyComponent {
>>   fooService;
>>   constructor(fooService: FooService) { this.fooService = fooService; }
>> }
>>
>> As will this TypeScript:
>> export class MyComponent {
>>   constructor(private fooService: FooService) { }
>> }
>>
>>
>> On Tuesday, October 18, 2016 at 6:40:10 AM UTC-5, Darren Chiu wrote:
>>>
>>> does anyone know how to compile the angular2 code into bundle with AoT 
>>> instead of JiT with ES6? Couldn't found any tutorials or guide and for 
>>> ES6... I know it was probably a wrong choice to use ES6 over typescript 
>>> with angular2 but I have a huge ES6 angular2 project already...
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to