admin管理员组

文章数量:1399909

After having done a bad manipulation on WebStorm, I now have errors such as expecting newline or semicolon". For example after an async or await. Even having disabled all my rules in Languages Injections I still have the same problem.

Followed this topic

async function reactEmoji(msg, index) {
  index = index - 1
  for (let i = 0; i < index; i++) {
      let emojiElement = emoji[i]
      await msg.react(emojiElement)
  }
}

Between async and function, I've got this error : Expecting newline or semicolon.

After having done a bad manipulation on WebStorm, I now have errors such as expecting newline or semicolon". For example after an async or await. Even having disabled all my rules in Languages Injections I still have the same problem.

Followed this topic

async function reactEmoji(msg, index) {
  index = index - 1
  for (let i = 0; i < index; i++) {
      let emojiElement = emoji[i]
      await msg.react(emojiElement)
  }
}

Between async and function, I've got this error : Expecting newline or semicolon.

Share Improve this question edited Jul 18, 2019 at 15:15 LazyOne 166k48 gold badges414 silver badges415 bronze badges asked Jul 18, 2019 at 13:17 ThomasThomas 331 gold badge2 silver badges7 bronze badges 2
  • 5 Make sure the language level for the project is set to ES6 and not ES5. Go to Settings->Languages & Frameworks->JavaScript and set it to ECMAScript 6. – Randy Casburn Commented Jul 18, 2019 at 13:20
  • A semicolon is optional in es6+. If you are coding es5, you should consider warning. Otherwise, change the javascript version in the Editor to get rid of this warning. – Artin Falahi Commented Jul 18, 2019 at 13:26
Add a ment  | 

1 Answer 1

Reset to default 4

this can be caused by a lot of different issues. One of the most likely ones is that your language is set to ES5 instead ES6, or even something else.

Old versions of javascript don't even know the async keyword, resulting in an error between async and function, as async is an unknown variable at this point.

To solve this issue, you can go to Settings -> Leanguages & Frameworks -> Javascript and check what value is set there. I suppose you'll want to set this to ECMAscript 6 if you are using a transpiler, else you would probably want ES2015/ECMAscript 5.

本文标签: javascriptExpecting newline or semicolon error on WebStormStack Overflow