colinbate / ng2-brunch

Basic Brunch skeleton for Angular 2 with TypeScript.
40 stars 19 forks source link

ES6 spread syntax not getting compiled #15

Open zxshinxz opened 8 years ago

zxshinxz commented 8 years ago

Hi there,

Thank you very much for angular2 brunch seed project.

Just reporting a problem where, whenever I use es6 spread syntax, It fails to compile.

e.g.


private getMaxY(): number {
    let maxValuesOfAreas = [];
    this.config.forEach(data => maxValuesOfAreas.push(Math.max.apply(Math, data.dataset.map(d => d.y))));
    return Math.max(...maxValuesOfAreas);
  }

08 Nov 13:47:04 - error: Compiling of app/directives/area-chart/area-chart.component.ts failed.  

If I change

    return Math.max(...maxValuesOfAreas); 

to

 return Math.max.apply(this,maxValuesOfAreas)(); 

works fine.

would there be specific typescript config for this issue.

Thank you Andy

colinbate commented 7 years ago

I'm not sure your issue is with the spread operator specifically. I use it a fair bit without problem. It is possible that using it is causing some helper to be compiled in which is triggering an error because of the isolated way in which brunch-typescript compiles.

Check out https://github.com/baptistedonaux/brunch-typescript#errors and try disabling the errors, it is possible that it will produce the correct output, and the error is a side effect of how it is being compiled.