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

explicit-any plugin fails to parse arrow function with implicit return of a literal object #113

Closed
rdsedmundo opened this issue Apr 29, 2021 · 5 comments · Fixed by #114
Closed

Comments

@rdsedmundo
Copy link

Command: yarn ts-migrate-full ./test-project --plugin explicit-any

Input:

export const fn = ({ arg }) => {
  return {
    a: arg.map((b) => ({
      c: b.property,
    })),
  };
};

Output:

export const fn = ({
  arg
}: any) => {
  return {
    a: arg.map((b: any) => {
      c: b.property,
    }),
  };
};

The surrounding parenthesis are being removed.

@rdsedmundo
Copy link
Author

Downgrading to 0.1.16 makes it work again. I had to force the resolution on Yarn by the way, because the main package releases the dependent packages with a caret (ˆ) in the version, so it always picks up the latest—might be something worth changing).

@rdsedmundo
Copy link
Author

rdsedmundo commented Apr 29, 2021

@edsrzf From my investigation I think this is related to the latest dependencies update you did, somehow it broke the logic we have for diagnostic.code=7006. Could you please have a look?

@edsrzf
Copy link
Collaborator

edsrzf commented Apr 30, 2021

Yep, will do. Thanks for all the detail.

@edsrzf
Copy link
Collaborator

edsrzf commented Apr 30, 2021

It looks like this was introduced when we upgraded jscodeshift in #106. Trying to figure out the appropriate fix...

@edsrzf
Copy link
Collaborator

edsrzf commented Apr 30, 2021

Upstream issue is here: benjamn/recast#743 (recast is a jscodeshift dependency)

Two PRs claiming to fix it, unreviewed and unmerged:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants