3

Jetbrains Webstorm keeps showing "Unterminated statement" for the code below.

@connect(props)
class NavBar extends Component {...}

But the message vanishes as I put a semicolon right after the decorator. I was just wondering if I have to put a semicolon after the decorators.

@connect(props);
class NavBar extends Component {...}
2
  • I would not, especially if they decorate a declaration that doesn't use semicolons on its own.
    – Bergi
    Sep 12, 2015 at 14:59
  • 4
    I suspect Webstorm doesn't know about decorators, so it thinks those are function calls.
    – Barmar
    Sep 12, 2015 at 15:01

1 Answer 1

4

No, you should not. According to the draft grammar, decorators are expressions that are part of a method or class definition. They are no statements, and must not end in semicolons.

Imo, using semicolons there would visually separate the decorator from the decoratee, which looks odd - especially if not even the decorated value ends in a semicolon. Looks like WebStorm just doesn't understand decorator syntax yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.