`unreachable code after return statement` warning
See original GitHub issueWhat version of Next.js are you using?
11.0.1
What version of Node.js are you using?
14.17.0
What browser are you using?
Firefox
What operating system are you using?
Fedora 34
How are you deploying your application?
next start
Describe the Bug
The browser prints the unreachable code after return statement
warning. This only happens in production and not with next dev
.
The error refers to the last return statement of this piece of code so it has something to do with the i18n routing.
Expected Behavior
It doesn’t print the error
To Reproduce
Create a new application with yarn create next-app
. Set the following configuration in next.config.js
:
module.exports = {
reactStrictMode: true,
i18n: {
defaultLocale: "en",
locales: ["en"],
},
}
Run yarn build && yarn start
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
javascript Warning: unreachable code after return statement
When an expression exists after a valid return statement, a warning is given to indicate that the code after the return statement is...
Read more >Turn off “unreachable code after return statement” warning
The only way I know of getting around this warning is to put a condition that's always true in the return line: function...
Read more >Getting 'unreachable code after return statement' error in ...
I'm only receiving the unreachable code warning in production, not on dev, so what would you like in terms of a reproducible demo?...
Read more >Unreachable Statement Code Error in Java
An unreachable code return statement is typically a sign of a logical error within the program. Although there are several reasons why you...
Read more >Unreachable Code Error in Java
Have a return statement before them: When a return statement gets executed, then that function execution gets stopped right there. Therefore any ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@smitssjors if you move the last
return false
into anelse
it’ll be correctly tree shaken 👍E.g. this:
Feel free to open a PR changing this. I’ve already verified this will shake it away on https://try.terser.org/
Reference code that is passed to Terser (sort of, it's not exactly this)
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.