facebook / facebook/jscodeshift

Merge calls to curried function

Đang mở
#369 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
10k
Fork
498
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

lodash/fp supports currying, so you can have calls, like this:
`set(key)(value)(obj)`
And I'd like to use a codemod to change them to be a single call, like this:
`set(key, value, obj)`

But I can't figure out how to get the args from the follow on calls (which appear to come before in the iteration) and make a single call. Is there a way to do this with the current version of `jscodeshift`? If not, can this be considered a bug?

Here's the error:
```
ERR web/sockets/PubSubWatcher.js Transformation error ([{ type: TemplateLiteral, start: 654, end: 671, loc: [object Object], expressions: [object Object], quasis: [object Object],[object Object] }, [{ type: MemberExpression, start: 682, end: 696, loc: [object Object], object: [object Object], property: [object Object], computed: false }]] does not match field "arguments": [Expression | SpreadElement] of type CallExpression)
Error: [{ type: TemplateLiteral, start: 654, end: 671, loc: [object Object], expressions: [object Object], quasis: [object Object],[object Object] }, [{ type: MemberExpression, start: 682, end: 696, loc: [object Object], object: [object Object], property: [object Object], computed: false }]] does not match field "arguments": [Expression | SpreadElement] of type CallExpression
at addParam (/usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:447:27)
at /usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:470:25
at Array.forEach ()
at Function.callExpression (/usr/local/lib/node_modules/jscodeshift/node_modules/ast-types/lib/types.js:468:35)
at NodePath. (/Users/dlj/projects/numetric.other/tools/code/migrate-curry.js:56:22)
at NodePath. (/usr/local/lib/node_modules/jscodeshift/src/collections/Node.js:142:47)
at /usr/local/lib/node_modules/jscodeshift/src/Collection.js:75:36
at Array.forEach ()
at Collection.forEach (/usr/local/lib/node_modules/jscodeshift/src/Collection.js:74:18)
at Collection.replaceWith (/usr/local/lib/node_modules/jscodeshift/src/collections/Node.js:140:17)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.