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

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

Description

@arackaf

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo