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
Allow extending untranspiled classes #8656
Merged
nicolo-ribaudo
merged 1 commit into
babel:master
from
nicolo-ribaudo:extend-native-class-2
Mar 16, 2020
Merged
Allow extending untranspiled classes #8656
nicolo-ribaudo
merged 1 commit into
babel:master
from
nicolo-ribaudo:extend-native-class-2
Mar 16, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nicolo-ribaudo
added
PR: New Feature 🚀
A type of pull request used for our changelog categories
Spec: Classes
labels
Sep 9, 2018
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9056/ |
xtuc
reviewed
Sep 10, 2018
This was referenced Feb 10, 2019
Any update? I have posted a question on StackOverflow which I think is related to this: |
minrk
added a commit
to executablebooks/thebe
that referenced
this pull request
Aug 6, 2019
babel can't transpile classes that extend native classes babel/babel#8656
minrk
added a commit
to executablebooks/thebe
that referenced
this pull request
Aug 6, 2019
babel can't transpile classes that extend native classes babel/babel#8656
minrk
added a commit
to executablebooks/thebe
that referenced
this pull request
Aug 6, 2019
babel can't transpile classes that extend native classes babel/babel#8656
Merge please. |
Hey! |
+1 for getting this merged - thanks! |
nicolo-ribaudo
force-pushed
the
extend-native-class-2
branch
from
January 1, 2020 14:54
072d362
to
58c5857
Compare
great! |
JLHwung
reviewed
Jan 20, 2020
nicolo-ribaudo
force-pushed
the
extend-native-class-2
branch
from
February 1, 2020 00:35
805390f
to
af5fc16
Compare
nicolo-ribaudo
force-pushed
the
extend-native-class-2
branch
from
March 5, 2020 01:37
18f3901
to
53ff542
Compare
JLHwung
approved these changes
Mar 11, 2020
JLHwung
force-pushed
the
extend-native-class-2
branch
from
March 11, 2020 22:09
53ff542
to
dc76b43
Compare
This was referenced Apr 12, 2020
This was referenced Apr 20, 2020
This was referenced Apr 27, 2020
This was referenced May 5, 2020
github-actions
bot
added
the
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
label
Jun 16, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
PR: New Feature 🚀
A type of pull request used for our changelog categories
PR: Ready For Review
Spec: Classes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prev: #7081
This PR allows transpiled classes to extends untranspiled classes. This can happen, for example, when a dependency is transpiled using Babel and extends an user-provided class.
Example: Oblosys/react-lifecycle-visualizer#4
The new helper only allows extending native classes when
Reflect.construct
is natively supported. Some envs (e.g. Node 4) have partial support for classes but don't provideReflect.construct
: in this case users need to ensure that every class (also in their dependencies) is transpiled, like it was before.[1] If someone sets
.constructor
to something else, the new helper won't work. e.g.A workaround to avoid the breaking change could be to only use the
Reflect
-based version of the helper only ifFunction.toString.call(SuperClass).slice(0, 5) === "class"
, but in those casesthis.constructor
still can't be modified.