0

I use the double colon this:: syntax for calling private methods in my VSCode React app, which invariably gives a } expected error line as well as several other error lines below it as a result. I am using the JavaScript Standard Style and have the Prettier extension enabled. I want to find whatever rule governs this usage and allow its use.

I've looked through the VSCode settings and extension settings to try to identify what rule conflict with no luck.

function renderMobileExpanded() {
  return (
    this.state.expanded && (
      <div styleName="collapsed-portion">
        <div className="container" onClick={this::handleLinkClick}>
          <ul>{this.props.children}</ul>
          {this.props.subnavLinks && (
            <ul styleName="subnav">{this.props.subnavLinks}</ul>
          )}
        </div>
      </div>
    )
  )
}

I expect to be able to use this double colon syntax without it throwing my linter into a small panic.

  • 3
    `::` syntax is not javascript, so you'll have to get something that compiles it I guess. Or just use `this.` – pmkro Apr 04 '19 at 20:14
  • I believe this syntax has been [proposed](https://stackoverflow.com/questions/27849064/how-to-implement-private-method-in-es6-class-with-traceur) The code compiles and runs as I have it so it must be recognized as correct javascript at some point when I run it. – Patrick Lewis Apr 04 '19 at 21:40
  • 1
    I have get to find anything regarding that, and the link you posted has reference to something that is not found in the [TC39 Proposals](https://github.com/tc39/proposals). My guess is it was implemented somewhere in your build pipeline, even though its not officially proposed. As for the linter errors, probably nothing you can do. – pmkro Apr 04 '19 at 21:54
  • Ok thanks for the help :) – Patrick Lewis Apr 04 '19 at 21:56

0 Answers0