Skip to content

unreachable code diagnostic should be severity suggestion, not error #24026

Closed
@alexeagle

Description

@alexeagle

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 condititonal if (1==1) throw new Error('')

I think unreachable code is not an invalid TypeScript program and therefore should be treated like an unused variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions