shuhei / babel-plugin-angular2-annotations

A babel transformer plugin for Angular 2 annotations
80 stars 9 forks source link

@Inject() Throwing Unexpected Token #22

Closed amcdnl closed 8 years ago

amcdnl commented 8 years ago

Getting errors compiling when using @Inject like documented here.

The error is vague but here is the code:

import { Component, Inject } from '@angular/core';
import { adapter } from 'app/adapter.js';

@Component({
  selector: 'app',
  providers: [ adapter.upgradeNg1Provider('$http') ],
})
export class App {
   constructor(element: ElementRef, @Inject('$http') $http) {}
}

and error reads like:

Error: C:/dev/app.js: Unexpected token

my versions are:

"babel-core": "^6.8.0",
"babel-preset-angular2": "0.0.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0",

with the following babel config:

"babel": {
    "sourceMaps": false,
    "presets": [
      "es2015",
      "stage-0",
      "angular2"
    ],
    "moduleIds": false,
    "comments": true,
    "compact": false
  }
shuhei commented 8 years ago

I'm not sure but it looks like an parser error on a decorator or something. Do you mind positing the actual stacktrace?

amcdnl commented 8 years ago

I upgraded node and reinstalled all my npm packages this morning and it works now? Maybe something cached in my npm conflicting. Sorry to bother!

shuhei commented 8 years ago

I see. Thanks for letting me know potential bugs anyway!