Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.arrowFunctionExpression not accepting arguments listed in documentation #12319

Closed
1 task done
deificx opened this issue Nov 6, 2020 · 3 comments
Closed
1 task done
Labels
i: docs outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@deificx
Copy link
Contributor

deificx commented Nov 6, 2020

Bug Report

  • I would like to work on a fix!

Current behavior

I want to generate an arrow function with a returnType, but before getting that far (in listing arguments) it seems to fail after adding 3.

Input Code

const t = require("@babel/types");
const body = t.blockStatement([t.returnStatement(t.booleanLiteral(true))]);
const fn = t.arrowFunctionExpression([], body, false, false);

Result

Error: ArrowFunctionExpression: Too many arguments passed. Received 4 but can receive no more than 3
    at builder (node_modules/@babel/types/lib/builders/builder.js:21:11)
    at Object.arrowFunctionExpression (node_modules/@babel/types/lib/builders/generated/index.js:470:31)
    at Object.<anonymous> (index.js:3:14)

Expected behavior

I would expect to be able to pass the arguments listed in the documentation.

Environment

  • Babel version(s): "@babel/types": "^7.12.6"
  • Node/npm version: v14.9.0

Not sure more details are needed here

Possible Solution

I started digging a bit in the code

So I'm a bit stuck.

@babel-bot
Copy link
Collaborator

Hey @deificx! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@JLHwung
Copy link
Contributor

JLHwung commented Dec 14, 2020

The documentation you refers to is the shape of the returned AST node, while the signature have only three arguments

t.arrowFunctionExpression(params, body, async)

Will be appreciated you can improve the babel types docs a bit.

@nicolo-ribaudo
Copy link
Member

Closing since the docs already specify only three parameters.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: docs outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants