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

Error when running rename-unsafe-lifecycles #254

Open
wesleyyee opened this issue Feb 12, 2020 · 9 comments
Open

Error when running rename-unsafe-lifecycles #254

wesleyyee opened this issue Feb 12, 2020 · 9 comments

Comments

@wesleyyee
Copy link
Contributor

wesleyyee commented Feb 12, 2020

Seeing this error when running rename-unsafe-lifecycles:

Error: did not recognize object of type "ImportExpression"
    at Object.getFieldNames (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/ast-types/lib/types.js:701:19)
    at getSortedChildNodes (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:50:23)
    at getSortedChildNodes (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:63:9)
    at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:73:22)
    at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:84:13)
    at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:84:13)
    at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:84:13)
    at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:84:13)
    at /Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:129:9
    at Array.forEach (<anonymous>)```
@threepointone
Copy link
Contributor

Could you try to isolate what file this happened on? If you could make a git repo with a reduced usecase, that would be excellent.

Just to be sure that it isn’t related to your own dependencies, would you also try running this from outside your project? ie- instead of cd my-project and npx react-codemod ..., could you run `npx react-codemod my-project‘?

@wesleyyee
Copy link
Contributor Author

Ahh it seems to not like React.lazy

@wesleyyee
Copy link
Contributor Author

@threepointone
Copy link
Contributor

Very helpful, thank you! I'll have a look this weekend.

@Jayphen
Copy link

Jayphen commented May 15, 2020

@threepointone Did you ever solve this? I have a similar problem in a codemod I am writing where it chokes on the dynamic import.

Not using React.lazy, but same syntax with loadable:

const Dooby = loadable(
  () => import('dooby/doo'),
  {
    fallback: <LoadingPage />
  }
);

@threepointone
Copy link
Contributor

I'm not doing any active development on this, but I'd be happy to review and land a PR with a fix.

@sterlu
Copy link

sterlu commented Aug 24, 2020

Hey, not sure if related, but also getting a similar error Error: did not recognize object of type "ChainExpression" with the same stack trace when running rename-unsafe-lifecycles

@rbalmf
Copy link

rbalmf commented Oct 11, 2020

@sterlu I had the same ChainExpression error when running over our large non-TS codebase - it seems to choke on optional chaining operators ?..

By telling the codemod to treat the code as Typescript it worked though.

@parthakshay
Copy link

try npx react-codemod rename-unsafe-lifecycles it'll work

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

No branches or pull requests

6 participants