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 |
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.
Which produces
Adding a junk placeholder at the end fixes it, as a workaround
Babel Configuration (.babelrc, package.json, cli command)
Your Environment