reflective-bind icon indicating copy to clipboard operation
reflective-bind copied to clipboard

Conflicts with idx

Open dmnd opened this issue 6 years ago • 0 comments

The following file errors when the idx transform is present too.

file.jsx:

/* eslint-disable flowtype/require-valid-file-annotation, no-unused-vars, flexport/must-have-team */

import * as React from "react";
import idx from "idx";

// Note: using just a div won't error
function Foo() {}

function DoesntCompile() {
  return <Foo onSomething={() => idx({}, _ => _.bar)} />;
}

Error:

$ yarn -s babel file.jsx
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist`
SyntaxError: /Users/dmnd/github/flexport/file.jsx: The `idx` function takes exactly two arguments. (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/Users/dmnd/github/flexport/node_modules/@babel/core/lib/transformation/file/file.js:261:12)
    at checkIdxArguments (/Users/dmnd/github/flexport/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js:20:18)
    at visitIdxCallExpression (/Users/dmnd/github/flexport/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js:97:5)
    at /Users/dmnd/github/flexport/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js:148:11
    at Array.forEach (<anonymous>)
    at Object.ImportDeclarationVariableDeclarator (/Users/dmnd/github/flexport/node_modules/babel-plugin-idx/lib/babel-plugin-idx.js:144:51)
    at NodePath._call (/Users/dmnd/github/flexport/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/dmnd/github/flexport/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/dmnd/github/flexport/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/dmnd/github/flexport/node_modules/@babel/traverse/lib/context.js:118:16)
error Command failed with exit code 1.

Babel config is here, but briefly both ["reflective-bind/babel", {propRegex: "^on[A-Z].*$"}] and "babel-plugin-idx" are present in that order.

dmnd avatar Jul 29 '19 20:07 dmnd