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

Transformation error (did not recognize object of type "ChainExpression") #48

Closed
connorjclark opened this issue Dec 15, 2021 · 4 comments · Fixed by #49
Closed

Transformation error (did not recognize object of type "ChainExpression") #48

connorjclark opened this issue Dec 15, 2021 · 4 comments · Fixed by #49

Comments

@connorjclark
Copy link
Contributor

connorjclark commented Dec 15, 2021

Seems the codemod does not support running on code that already utilizes optional chaining.

lighthouse-core/computed/metrics/timing-summary.js Transformation error (did not recognize object of type "ChainExpression")
Error: did not recognize object of type "ChainExpression"
    at Object.getFieldNames (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/types.js:661:19)
    at visitChildren (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:186:36)
    at Visitor.PVp.visitWithoutReset (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:168:20)
    at visitChildren (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:205:25)
    at Visitor.PVp.visitWithoutReset (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:168:20)
    at NodePath.each (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path.js:89:26)
    at visitChildren (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:180:18)
    at Visitor.PVp.visitWithoutReset (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:168:20)
    at visitChildren (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:205:25)
    at Visitor.PVp.visitWithoutReset (/Users/cjamcl/.npm/_npx/42135/lib/node_modules/optional-chaining-codemod/node_modules/ast-types/lib/path-visitor.js:168:20)

I believe it was resolved here: benjamn/ast-types#383

@villesau
Copy link
Owner

@connorjclark can you give a small snippet to reproduce? I was able to run it against const result = a?.b?.[0].something;

@villesau
Copy link
Owner

Updated jscodeshift, that might fix the issue.

@connorjclark
Copy link
Contributor Author

It sure did! thanks for the quick turnaround, and for the nice tool :)

@villesau
Copy link
Owner

No worries, great to see that the tool has been useful in such a great project I use my self as well! :)

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