0

Trying to set up a Babel environment for this JSBin: https://jsbin.com/taquke/edit?js,output

This is my package.json:

{
  "name": "babel",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.10.1",
    "babel-plugin-transform-object-rest-spread": "^6.8.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1"
  }
}

This is my .babelrc:

    {
      "presets": ["es2015", "react"],
      "plugins": ["transform-object-rest-spread"],
      "env": {
        "development": {

        }
      }
    }

+I've defined a file watcher for WebStorm (to babel).

I'm getting this when saving the JS file: babel error

Any idea?

Guy
  • 12,488
  • 16
  • 79
  • 119
  • Possible duplicate of [can i use ES6 fat arrow in class methods?](http://stackoverflow.com/questions/31362292/can-i-use-es6-fat-arrow-in-class-methods) – azium Jul 06 '16 at 18:00
  • There syntax is different, isn't it, there is an equal sign there – Guy Jul 06 '16 at 18:04
  • There is an equal sign in yours too, that's what it's crashing on... – azium Jul 06 '16 at 18:06
  • In any case, the answer to that question **is** the answer to your question.. you need the correct babel transform / plugin to handle class arrow properties – azium Jul 06 '16 at 18:09
  • babel-preset-es2015 should cover that. – ffxsam Jul 06 '16 at 19:10
  • You're missing a variable declaration. Use either `const` or `let` before `renderChild`. – searsaw Jul 06 '16 at 20:43

1 Answers1

0

Class properties isn't part of ES2015.

If you would like to define properties directly in a class definition, you should enable babel-plugin-transform-class-properties or maybe the whole babel-preset-stage-1.

just-boris
  • 9,468
  • 5
  • 48
  • 84