Any way to enable ES7 static properties?

I’m having a hard time finding a concrete answer on using static properties in Meteor. Is there any way to opt into the ES7 static properties? (besides using webpack)

eg

class Baz extends React.Component {
  static propTypes = {
    foo: t.string,
    bar: t.string.isRequired,
  };
  ....
}

Also semi related I would like to try decorators with @observable for mobx but it also seems like these are unsupported?

1 Like

Adding the following to your package.json should suffice, of course you can tweak this to your more specific requirements:

  "devDependencies": {
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-stage-0": "^6.22.0"
  },
  "babel": {
    "plugins": [
      "transform-decorators-legacy"
    ],
    "presets": [
      "stage-0"
    ]
  }

Of course, you can do this by including this within a .babelrc file which is at the root of your project, which should be a more flexible way, additionally giving you the ability to use that on your local packages, as opposed to including it within package.json which only provides this to your non-package code.

2 Likes

This works great, many thanks!!

1 Like

I was using hoist-non-react-statics but a babel approach seems better

2 Likes