Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Bug - decorator with computed name at end of class #231

Closed
arackaf opened this issue Nov 21, 2016 · 3 comments
Closed

Bug - decorator with computed name at end of class #231

arackaf opened this issue Nov 21, 2016 · 3 comments

Comments

@arackaf
Copy link

arackaf commented Nov 21, 2016

re-opening this case

babel/babel#4866 (comment)

here by request.

It looks like Babel is erroring out when there's a decorated class property method as the last statement in a class.

const mixin = options => Class => class sub extends Class {
    @action [options.foo] = () => true;
};

Which produces

SyntaxError ...... You have trailing decorators with no method (68:1)

Adding a junk placeholder at the end fixes it, as a workaround

const mixin = options => Class => class sub extends Class {
    @action [options.foo] = () => true;

    __junk;
};

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

{
  "name": "transpiler",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-preset-es2015": "6.18.0",
    "babel-preset-react": "6.16.0",
    "babel-preset-stage-2": "6.18.0",
    "del": "2.2.2",
    "gulp": "3.9.1",
    "gulp-babel": "6.1.2",
    "gulp-if": "2.0.0",
    "gulp-line-ending-corrector": "1.0.1",
    "gulp-notify": "2.2.0",
    "gulp-plumber": "0.6.6",
    "gulp-print": "1.1.0",
    "gulp-rename": "1.2.0",
    "jest": "15.1.1",
    "jest-cli": "15.1.1"
  },
  "jest": {
    "testPathDirs": ["test"],
    "modulePaths": ["2"],
    "testRegex": ".js$",
    "moduleNameMapper": {
      "^react$": "assets/react/react",
      "^react-dom$": "assets/react-dom/react-dom",
      "^mobx$": "assets/mobx/mobx",
      "^mobx-react$": "assets/mobx-react/index.js",
      "^bootstrap-dropdown-button$": "assets/react-bootstrap/buttonDropdown.js"
    },
    "testPathIgnorePatterns": [
      "test/mocks/"
    ]
  },
  "scripts": {
    "preinstall": "npm install -g gulp@3.9.1",
    "test": "jest"
  }
}

Your Environment

software version
Babel see above
node 4.4.5
npm 3.9.5
Operating System Windows 10
@DrewML
Copy link
Member

DrewML commented Nov 21, 2016

Thanks! Looks like we have a few updates we're going to need to make for compliance with the latest draft of the spec.

@peey
Copy link
Contributor

peey commented Jun 23, 2017

Even though this issue isn't fixed, I'm not sure if it should be closed or not. Old decorators plugin is unlikely to be maintained, but this will nice to have as a test case when the support for decorated class properties lands in babylon.

Same thoughts for #232

@babel-bot
Copy link

This issue has been moved to babel/babel#6714.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants