babel-plugin-pipe-operator icon indicating copy to clipboard operation
babel-plugin-pipe-operator copied to clipboard

[help] usage with Typescript and react-native

Open rthomazel opened this issue 7 years ago • 0 comments

I'm trying to use this plugin in my metro bundler with react-native and ts, but I get the following js bundle error:

Loading dependency graph, done.
error: bundling failed: TypeError: Expected node path of type CallExpression
    at NodePath.<computed> [as assertCallExpression] (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/path/index.js:206:13)
    at PluginPass.BinaryExpression (/Users/vamac/Desktop/scaMo/node_modules/babel-plugin-pipe-operator/lib/index.js:26:19)
    at newFn (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitSingle (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/context.js:90:19)
    at TraversalContext.visit (/Users/vamac/Desktop/scaMo/node_modules/@babel/traverse/lib/context.js:146:19)

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['pipe-operator'],
}

I'm not sure what part of my tool chain is not working right. Here's the code I'm trying to apply the plugin on:

import { map, filter } from 'lodash';

const array = [1, 2, 3, 4, 5];

// @ts-ignore
const arr = array | map(n => n * 2)

console.log('arr', arr)

Thanks for any guidance, I have a feeling this is something simple.

rthomazel avatar Jun 04 '19 14:06 rthomazel