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

@babel/plugin-proposal-decorators legacy failure to meet expectations #8993

Open
zhipenglin opened this Issue Nov 8, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@zhipenglin

zhipenglin commented Nov 8, 2018

v7 Regression

First check out: https://new.babeljs.io/docs/en/next/v7-migration.html
Also a partial upgrade tool: https://github.com/babel/babel-upgrade

Potential Commit/PR that introduced the regression
If you have time to investigate, what PR/date introduced this issue.

Describe the regression
A clear and concise description of what the regression is.

Input Code

@withRouter
@function(WrappedComponent){
     return class extends Component{
          render(){
                return <div className="test-name"><WrappedComponent /></div>
          }
    }
}
class SomeComponent extends Component{
    render(){
       return 'test'; 
   }
}

Babel Configuration (.babelrc, package.json, cli command)

{
  plugins:[
    [require.resolve('@babel/plugin-proposal-decorators'), {legacy: true}],
     [require.resolve('@babel/plugin-proposal-class-properties'), {loose: true}]
]
}

The decorator did not take effect.

const someHoc=function(WrappedComponent){
     return class extends Component{
          render(){
                return <div className="test-name"><WrappedComponent /></div>
          }
    }
};

@withRouter
@someHoc
class SomeComponent extends Component{
    render(){
       return 'test'; 
   }
}

When I modify the code like this, it works normally.

Expected behavior/code
A clear and concise description of what you expected to happen (or code).

Environment

  • Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
  • Node/npm version: [e.g. Node 8/npm 5]
  • OS: [e.g. OSX 10.13.4, Windows 10]
  • Monorepo [e.g. yes/no/Lerna]
  • How you are using Babel: [e.g. cli, register, loader]
@babel-bot

This comment has been minimized.

Collaborator

babel-bot commented Nov 8, 2018

Hey @zhipenglin! 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.

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