unreachable code diagnostic should be severity suggestion, not error #24026
Labels
Domain: Error Messages
The issue relates to error messaging
Fixed
A PR has been merged for this issue
Suggestion
An idea for TypeScript
Milestone
Thanks to #19392 we can now produce Suggestions with Code Fixes rather than error diagnostics.
This is a good way for TypeScript to report that a program is valid TypeScript, but likely contains a mistake.
Unreachable code is exactly this case. Developers sometimes add a quick
throw
statement just to make a runtime assertion while debugging. Then they get an error diagnostic which forces them to comment out remaining lines in this control flow, or add a fake guard condititonalif (1==1) throw new Error('')
I think unreachable code is not an invalid TypeScript program and therefore should be treated like an unused variable.
The text was updated successfully, but these errors were encountered: