Editor Bug {code blocks in switches seen as errors}

Code blocks within switches are perfectly valid JavaScript and should not show as errors.

Not sure what you mean there. Where are you getting errors?

We don’t throw our own code errors. If you are getting some error messages somewhere that would be the browser.

Although switch case blocks are best written without braces, I recently added braces within a switch case block and the editor flagged the code with red error indicators rather than warning indicators. There weren’t any actual errors thrown in running the code, only indicator flags in the left side of the editor by the line numbers.

OK I see what you mean now. There is some static analysis of the code in the code editor and it will often show things with a red flag. These are not necessarily errors but things the analyzer considers bad. This is a plug-in that we use not written by us.

Thanks for the clarification. Have a great day.

@Eric_Eisaman You are only receiving this error because {code blocks} are not necessary inside switchs, the “break” keyword is used instead to break out of the switch block. It is explained in futher detail on other sites like W3Schools and Mozzila Developer Network. These links will bring you to their Javascript switch page.

Thanks for the reply PiggahBro. I know braces aren’t necessary within case blocks. I was implementing if/else blocks within case blocks so I added the additional and unnecessary curly braces as syntactic sugar. My concern was targeting visual flags/cues shown in the editor, namely that visual cues provided by editors should not be ambiguous. The PC editor uses the same visual cue for legitimate JavaScript errors as it does for valid JavaScript with syntax it recommends against. I suggest a smarter editor that would show a yellow or orange cue in the second case.
Cheers. :birthday: