speedskater/babel-plugin-rewire

Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got "CallExpression"

Closed this issue · 1 comments

Got the following error during transpilation:

Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got "CallExpression"

for the following code:

'use strict';

var eventmap = [];
var eventname = '';
var ron = /^on/;

for (eventname in global) {
  if (ron.test(eventname)) {
    eventmap.push(eventname.slice(2));
  }
}

module.exports = eventmap;

changing to:

'use strict';

var eventmap = [];
var ron = /^on/;

for (var eventname in global) {
  if (ron.test(eventname)) {
    eventmap.push(eventname.slice(2));
  }
}

module.exports = eventmap;

produces no errors.

Might be related to #173

I'll have a PR with tests shortly, but wanted to report the issue here first. Thanks again for your work on this excellent plugin!

@mikesherov Thank you for providing the fix. It is incorporated into babel-plugin-rewire 1.1.0. I also added you to the list of contributors on the github page.