IntelliJ IDEA Syntax Error “Expression Expected” on Arrow Function

Recently I came upon an “Expression Expected” error reported by IntelliJ IDEA’s code analysis on an arrow function. It took me a while to figure out that the issue is related to JavaScript language version support for ECMAScript. Anyhow, the following explains how easy is to resolve the issue.

Example of IntelliJ IDEA Syntax Error “Expression Expected” on Arrow Function:

The JavaScript Arrow Function Expressions were introduced in ECMAScript 6 and thus to resolve the problem we need to support ECMAScript 6 in IntelliJ IDEA.

To do so, simply go to File / Settings / Languages & Frameworks / JavaScript

Then under the JavaScript language version, change it from the current ECMAScript version to ECMAScript version 6:

I hope this helped.

Comments

comments