Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest parameters error #251

Closed
thany opened this issue Sep 26, 2016 · 4 comments
Closed

Rest parameters error #251

thany opened this issue Sep 26, 2016 · 4 comments

Comments

@thany
Copy link

thany commented Sep 26, 2016

TL;DR: ng-annotate appears to choke on any code, even bits that don't need annotation, with rest params.

Consider this function then:

function foo(bar, ...more) {
  //Do whatever
}

As far as I can tell, stuff this somewhere in your code (make sure it doesn't get optimized away in some manner) and pull ng-annotate over it. It doesn't matter that this function has nothing to do with Angular, ng-annotate will error either way.

Error: StringMap expected string key
    at stringmap.set (D:\Klanten\qsdashboard\node_modules\stringmap\stringmap.js:100:19)
    at Scope.add (D:\Klanten\qsdashboard\node_modules\ng-annotate\build\es5\scope.js:102:17)
    at D:\Klanten\qsdashboard\node_modules\ng-annotate\build\es5\scopetools.js:65:25
    at Array.forEach (native)
    at createScopes (D:\Klanten\qsdashboard\node_modules\ng-annotate\build\es5\scopetools.js:64:21)
    at visit (D:\Klanten\qsdashboard\node_modules\ordered-ast-traverse\ordered-ast-traverse.js:25:19)
    at visit (D:\Klanten\qsdashboard\node_modules\ordered-ast-traverse\ordered-ast-traverse.js:46:21)
    at visit (D:\Klanten\qsdashboard\node_modules\ordered-ast-traverse\ordered-ast-traverse.js:43:25)
    at visit (D:\Klanten\qsdashboard\node_modules\ordered-ast-traverse\ordered-ast-traverse.js:43:25)
    at visit (D:\Klanten\qsdashboard\node_modules\ordered-ast-traverse\ordered-ast-traverse.js:46:21)

StringMap is not to blame, it seems. It's just trying to insert an key/value pair into a stringmap, for which key=undefined, and value is this object:

{ kind: 'param',
  node:
   Node {
     type: 'RestElement',
     start: 589009,
     end: 589019,
     loc: SourceLocation { start: [Object], end: [Object] },
     range: [ 589009, 589019 ],
     argument:
      Node {
        type: 'Identifier',
        start: 589012,
        end: 589019,
        loc: [Object],
        range: [Object],
        name: 'sources' } } }

This tells me, it is at least aware of rest params. It's just not supporting them correctly.

Please note: I'm not using any type of transpiler/cispiler of any kind. I'm using ES6 straight in the browser.

@olov
Copy link
Owner

olov commented Oct 1, 2016

#245

@olov olov closed this as completed Oct 1, 2016
@thany
Copy link
Author

thany commented Oct 28, 2016

So this project is abandoned?

@olov
Copy link
Owner

olov commented Oct 28, 2016

It's just about to be deprecated in favor of https://github.com/schmod/babel-plugin-angularjs-annotate/tree/next so there will be no new feature-releases. Thanks for using it and I hope you'll like its successor.

@thany
Copy link
Author

thany commented Oct 28, 2016

That's a sad thing to happen. Why would you let yourself be defeated? All you need is ES6 support, and node.js provides it beautifully.

There no reason to deprecate one package just because another similar one happens to exist. Besides, the one you referred is a Babel plugin, and I imagine setting up Babel (which I have absolutely no need for by itself) is a lot more pain than including ngAnnotate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants