Skip to content

Changing or reloading the current page via location should cause unreachable code errorΒ #62073

@kkmuffme

Description

@kkmuffme

πŸ”Ž Search Terms

location.reload location.href

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about unreachable code

⏯ Playground Link

https://www.typescriptlang.org/play/?ssl=13&ssc=1&pln=1&pc=1#code/FAMwrgdgxgLglgewgAhAhAKAlMg3sZQ5AJwFMYxiIBuYAogQwBtTiYMByAC1KaYQ5ZaAXzrho8JMgBGDYtjz1CAdzgQAJgmUA6flAaSI2svwbrstJcmat23Xv0EjgQA

πŸ’» Code

function foo() {
    return;

    alert('hello');
}

function bar() {
    window.location.reload();

    alert('hello');
}

πŸ™ Actual behavior

line 5: Unreachable code detected.

πŸ™‚ Expected behavior

line 5: Unreachable code detected.
line 11: Unreachable code detected.

Additional information about the issue

The same applies to when when assigning location.href = ... for example

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy