Skip to content

"Remove unreachable code" fix removes too much #25592

Closed
@jeffreymorlan

Description

@jeffreymorlan

TypeScript Version: 2.9.1, 3.0-rc

Search Terms: unreachable remove fix

Code

while (true) {
    console.log(1);
    break;
    console.log(2); // unreachable
}

Expected behavior:
"Remove unreachable code" fix should only remove the code after "break".

Actual behavior:
The fix removes the whole loop.

I guess the idea was that the body of an if (false) or while (false) is considered unreachable, and in that case the whole thing can be removed. But, that's not the case here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions