-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Enable TS type-only class fields by switching TS Babel from preset to transform plugin #9235
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
Enable TS type-only class fields by switching TS Babel from preset to transform plugin #9235
Conversation
Hi @pekala! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
So what are the things that broke? |
@sakalys It's most likely outdated |
@pekala, one thing to try is to update the PR by merging in the new master branch into your own. After that, make sure to run |
Hmm, I don't think it's that simple. |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
I ran into this issue and am interested in this fix |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Looks like there are conflicts now, but if this is all that needs to happen to be able to use |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Fixes #8918
Type-only class fields using the
declare
keyword were added by TS 3.7. CRA currently fails when it encounters them with the following error:Declare fields are useful when using React context in class components, e.g.:
This PR switches from Babel TS preset to Babel TS transform plugin in order to run the babel transform before
@babel/plugin-proposal-class-properties
. It also switches the support for declare fields by using theallowDeclareFields
option on the plugin. This will be the default for Babel 8, but for now, we need to use the option.The preset to plugin switch should have no other effect since the babel TS preset wraps only one plugin and provides little more than the transform plugin itself.