Add TypeScript Support#228
Add TypeScript Support#228skovy wants to merge 11 commits intoreactjs:masterfrom skovy:skovy/add-typescript-support
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.
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
jscodeshiftsupports TypeScript (added inv0.6.0) thereact-codemodscripts can also support TypeScript without any custom logic.Resolves #206.
Changes
jscodeshiftto get parser support for TypeScriptdefineTesthelper injscodeshift.js(not true for TypeScript)parserfor those that need it (some flow tests that now break with the newer version ofjscodeshift)rename-unsafe-lifecyclesto also replaceClassMethodfor TypeScript classesTesting
jscodeshiftlocally and checkout the branch with the necessary changesjscodeshiftdirectoryyarn linkyarn link jscodeshiftyarn test