-
Notifications
You must be signed in to change notification settings - Fork 286
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
Add TypeScript Support #228
Conversation
Sorry I missed this. I have another PR I'm trying to land today that updates jscodeshift as well #229 I'm trying to land this asap so we can do a react alpha release. |
Hey @threepointone, thanks for the heads up 👍 let me know if there are any changes I can make to help add TS support. Looks like you mostly have it in that PR and maybe the only thing left in this one are the tests and the one addition to the transform for renaming unsafe lifecycles? The tests I added to require a change to jscodeshift test utils to allow testing things other than js. |
I don't expect the jscodeshift PR to land any time soon, so I'd recommend using the Object.assign hack https://github.com/reactjs/react-codemod/blob/master/transforms/__tests__/rename-unsafe-lifecycles-test.js#L13-L17 I'm not sure of a workaround for the extension. To simplify, I'm happy to accept a PR with just this root
.find(j.ClassMethod)
.forEach(renameDeprecatedApis); in rename-unsafe-lifecycles.js, since that seems to be the core change. |
Thanks to @skovy in reactjs#228, we have a fix for this codemod not working correctly for typescript files. Making this a separate commit/PR to unblock publishing.
I made a separate PR for the same here #234 so I can publish an update this weekend. Thank you for the effort! |
closing this since #234 landed. |
@threepointone thanks for getting that merged. Should I pull out this test and use the |
Ideally so, but I’m not sure how you’ll run the tests in tsx files. Or is that not necessary? |
Thanks to @skovy in reactjs/react-codemod#228, we have a fix for this codemod not working correctly for typescript files. Making this a separate commit/PR to unblock publishing.
Thanks to @skovy in reactjs/react-codemod#228, we have a fix for this codemod not working correctly for typescript files. Making this a separate commit/PR to unblock publishing.
Note: this is a branch off #227 and it must be merged first.
Motivation
Now that
jscodeshift
supports TypeScript (added inv0.6.0
) thereact-codemod
scripts can also support TypeScript without any custom logic.Resolves #206.
Changes
jscodeshift
to get parser support for TypeScriptdefineTest
helper injscodeshift
.js
(not true for TypeScript)parser
for those that need it (some flow tests that now break with the newer version ofjscodeshift
)rename-unsafe-lifecycles
to also replaceClassMethod
for TypeScript classesTesting
jscodeshift
locally and checkout the branch with the necessary changesjscodeshift
directoryyarn link
yarn link jscodeshift
yarn test