5

VS Code doesn't recognize :: as valid syntax, as in

render() {
    return (
        <button
          className="btn btn-primary"
          onClick={::this.handleClick}>
        Click me
        </button>
    );
}

It highlights :: with an error [js] identifier expected and thus invalidates the whole file.

An ideas how to remedy that - make VS Code respect ES6 syntax?

Andrey
  • 20,487
  • 26
  • 108
  • 176
  • `::` is not part of ES6. It's an experimental feature: https://github.com/tc39/proposal-bind-operator . It's stage 0, so it might never even make it into the spec. – Felix Kling Jan 11 '17 at 14:38
  • It's supported by ES6 to ES5 compilers including Babel and is used in various ES6 examples all over the place, that's why I thought it's a standard feature – Andrey Jan 11 '17 at 14:42
  • Yes, Babel has plugins for some stage 0 proposals (https://babeljs.io/docs/plugins/preset-stage-0/), but you have to explicitly opt-in to it (as with everything in Babel actually). That's not to say that there isn't a way to get this to work (I don't know anything about VS), but it's also likely that it isn't possible. – Felix Kling Jan 11 '17 at 14:44
  • For me this answer is working: http://stackoverflow.com/questions/36327096/vscode-linter-es6-es7-babel-linter/36327097#36327097 – gandalfml Jan 26 '17 at 13:07

1 Answers1

3

Use extentions

Your code looks like React to me, so you could try https://marketplace.visualstudio.com/items?itemName=dzannotti.vscode-babel-coloring which could help with React style code and ES6/ES7

Furthermore, you can modify extention to suit your needs

v-andrew
  • 21,939
  • 6
  • 36
  • 41
  • 3
    But this extension doesn't support this operator (::). I cannot find any extension for this and I failed with adding it on my own (as well to this extension as to some new one). It should be easy job, but this language json files looks like black magik to me, could anyone try to help me with that? – gandalfml Jan 26 '17 at 12:15
  • @gandalfml you can update extention and add support for experimental feature ;) – v-andrew Jan 26 '17 at 14:26