Skip to content

Missing Parens. Syntax Error after transforming ArrowFn as Callee #5192

Closed

Description

@boopathi

When transforming CallExpression with ArrowFn as the callee to TaggedTemplate, a pair of parens doesn't get outputted.

http://astexplorer.net/#/K2CkvW8FLH

Edit: Also for FunctionExpression

Input Code

(() => {})("foo")

Babel Configuration (.babelrc, package.json, cli command)

{
  plugins: [
    ({types: t}) => ({
      visitor: {
        CallExpression(path) {
          path.replaceWith(
            t.taggedTemplateExpression(
              path.get("callee").node,
              t.templateLiteral(
                [ t.templateElement({ raw: path.get("arguments")[0].node.value }, true) ], []
              )
            )
          );
        }
      }
    })
  ]
}

Expected Behavior

(() => {})`foo`;

Current Behavior

() => {}`foo`

which is a SyntaxError.

Possible Solution

Context

Minify foo("bar") to

foo`bar`

Your Environment

software version
Babel 6.21
node 7
npm 4

Activity

  1. added
    outdated
    on May 5, 2018
  2. locked as resolved and limited conversation to collaborators on May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedpkg: generator

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions