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

The method `inherits` of babel-helpers is not executed properly #9270

Open
cadleo opened this Issue Jan 2, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@cadleo
Copy link

cadleo commented Jan 2, 2019

Bug Report

Current Behavior
@version7.2.0,emmmm,my english is so poor, click here to view the source code

  import setPrototypeOf from "setPrototypeOf";
  export default function _inherits(subClass, superClass) {
    if (typeof superClass !== "function" && superClass !== null) {
      throw new TypeError("Super expression must either be null or a function");
    }
    // Here, it replaced the prototype of subClass, the origin prototype will be lost?
    // Here, it replaced the prototype of subClass, the origin prototype will be lost?
    // Here, it replaced the prototype of subClass, the origin prototype will be lost?
    // Important things should be repeated for 3 times,forgive my recklessness,thx
    subClass.prototype = Object.create(superClass && superClass.prototype, {
      constructor: {
        value: subClass,
        writable: true,
        configurable: true
      }
    });
    if (superClass) setPrototypeOf(subClass, superClass);
  }

React class-component will lose its all custom method of prototype when the source code transpiled from ES6 to ES5

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Jan 2, 2019

Hey @cadleo! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@loganfsmyth

This comment has been minimized.

Copy link
Member

loganfsmyth commented Jan 3, 2019

You are correct that the original prototype is replaced, but it shouldn't have been used yet when the helper is executed, so it should not have any issues.

@cadleo

This comment has been minimized.

Copy link

cadleo commented Jan 3, 2019

You are correct that the original prototype is replaced, but it shouldn't have been used yet when the helper is executed, so it should not have any issues.

@loganfsmyth Thx,I have find the real problem,but I think maybe it is related to babel. In the npm package dva@2.4.1, the code of output-file lib/dynamic.js transpiled incorrect, it call createClass first,and then call inherits, and this leads to lose the original prototype of subClass, , is it a feature in babel 7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment