Skip to content

Comments moved after recast print #1272

@coderaiser

Description

@coderaiser
hello (/** @type {string} */ (a), b);

becames:

hello/** @type {string} */(b, a, b);

After:

export default function transformer(file, api) {
  const j = api.jscodeshift;

  return j(file.source)
    .find(j.CallExpression)
    .forEach(path => {
    const [, arg] = path.node.arguments;
      path.node.arguments.unshift(arg);
    })
    .toSource();
}

https://astexplorer.net/#/gist/79f2d0ef7de4aeb1a913a862217da9ec/9a2e487ad7159d9777bab7dac6d13990d94fc98c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions