Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 200 forks source link

"unreachable code after return statement" warning in Firefox #1787

Closed medihack closed 2 years ago

medihack commented 2 years ago

When adding Chevrotain to a project I get an "unreachable code after return statement" warning on the console in Firefox only. It is hard to tell exactly where it originates, maybe from the "cst-dts-gen" package (from what I can tell from the line Firefox shows me). I am also not sure if this problem only occurs in combination with Webpack, but I can easily reproduce it in a Next.js app.

I setup a little example repository. As soon as I import Chevrotain and use it (like here, the above warning occurs. It doesn't seem to break anything as far as I can tell.

bd82 commented 2 years ago

Without checking the example repo my initial gamble would be this line:

There was a previous issue about this here:

medihack commented 2 years ago

Alright, I guess that's it. Funky stuff :-) Maybe a condition that always returns true could get rid of the warning (see https://stackoverflow.com/a/34523915).

bd82 commented 2 years ago

Merged your PR @medihack but as this is not an urgent fix I will only create a release when a few more fixes/features are in master...