@babel/types. Wrong arity while executing callExpression
See original GitHub issueBug Report
- I would like to work on a fix!
Current Behavior Been looking into running a code-mod for our codebase. Our codebase is running Typescript through Babel. We are looking into extracting some types of some function calls to be reused in other parts of said codemod, but we cannot seem to be able to create a callExpression with more than 2 arguments.
On @babel/types
it shoes a conflicting doc. https://babeljs.io/docs/en/babel-types#callexpression
Input Code
Expected behavior/code I can execute t.callExpression to create an expression with types for their arguments or parameters.
https://babeljs.io/docs/en/babel-types#callexpression
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Added a simple code-sandbox here (I can work on a more complex environment if needed)
Environment
- Babel version(s):
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/types": "^7.8.3",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.3.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/polyfill": "7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.8.3",
"@babel/register": "^7.8.3",
- Node/npm version: v12.13.1 (using yarn)
- OS: OSX 10.14.6 (18G3020)
- Monorepo: No
- How you are using Babel: `cli` + `register`
Additional context/Screenshots
Actual error when running our code-mod
(node:48825) UnhandledPromiseRejectionWarning: Error: CallExpression: Too many arguments passed. Received 5 but can receive no more than 2
at builder (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/types/lib/builders/builder.js:21:11)
at Object.callExpression (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/types/lib/builders/generated/index.js:282:31)
at CallExpression (/Users/fforres/BREX/credit_card/product/dashboard/code_mods/styled_components/mod.ts:156:30)
at NodePath._call (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/path/context.js:88:12)
at TraversalContext.visitQueue (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/context.js:90:19)
at TraversalContext.visit (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/context.js:146:19)
at Function.traverse.node (/Users/fforres/BREX/credit_card/product/dashboard/node_modules/@babel/traverse/lib/index.js:94:17)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Type builders only have parameters for common/standard attributes. If you need to set more, you can use
Object.assign
:It’s
@babel/types
which is outdated. Fixed in a PR opened 5 mins ago 😛https://github.com/babel/babel/pull/11172