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

[Bug]: Error: undefined is not a valid recordAndTuple syntax type #15756

Closed
1 task done
coderaiser opened this issue Jul 6, 2023 · 1 comment · Fixed by #15757
Closed
1 task done

[Bug]: Error: undefined is not a valid recordAndTuple syntax type #15756

coderaiser opened this issue Jul 6, 2023 · 1 comment · Fixed by #15757
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@coderaiser
Copy link
Contributor

coderaiser commented Jul 6, 2023

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const parser = require('@babel/parser');
const traverse = require('@babel/traverse').default;

const ast = parser.parse('const a = #[1]', {
    sourceType: 'module',
    plugins: [
        'recordAndTuple'
    ],
});

traverse(ast, {
    TupleExpression(path) {
        console.log(path.toString());
    }
});

Configuration file name

No response

Configuration

No response

Current and expected behavior

Current beheviour is crash:

/Users/coderaiser/printer/node_modules/@babel/generator/lib/generators/types.js:136
    throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
    ^

Error: undefined is not a valid recordAndTuple syntax type
    at Generator.TupleExpression (/Users/coderaiser/printer/node_modules/@babel/generator/lib/generators/types.js:136:11)
    at Buffer.exactSource (/Users/coderaiser/printer/node_modules/@babel/generator/lib/buffer.js:239:7)
    at Generator.exactSource (/Users/coderaiser/printer/node_modules/@babel/generator/lib/printer.js:163:15)
    at Generator.print (/Users/coderaiser/printer/node_modules/@babel/generator/lib/printer.js:333:10)
    at Generator.generate (/Users/coderaiser/printer/node_modules/@babel/generator/lib/printer.js:51:10)
    at Generator.generate (/Users/coderaiser/printer/node_modules/@babel/generator/lib/index.js:19:18)
    at generate (/Users/coderaiser/printer/node_modules/@babel/generator/lib/index.js:90:14)
    at NodePath.toString (/Users/coderaiser/printer/node_modules/@babel/traverse/lib/path/index.js:129:35)
    at TupleExpression (/Users/coderaiser/printer/1.js:13:26)
    at NodePath._call (/Users/coderaiser/printer/node_modules/@babel/traverse/lib/path/context.js:46:20)

Would be great to receive string representation of path.

Environment

Latest versions.

Possible solution

Set default to hash in @babel/generator:

recordAndTupleSyntaxType: opts.recordAndTupleSyntaxType,

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @coderaiser! 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.

coderaiser added a commit to coderaiser/babel that referenced this issue Jul 6, 2023
JLHwung added a commit that referenced this issue Jul 6, 2023
* fix: TupleExpression to String (#15756)

* Update packages/babel-generator/src/index.ts

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>

---------

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
@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 Oct 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: needs triage 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.

2 participants