You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
If you uncomment the early return in the doAThing function (common temp change to disable some stuff for debugging), nothing should happen (allowUnreachableCode is enabled in playground options)
Actual behavior:
TypeScript now fails to perform the type-narrow from the if statement, causing a type error on the assignment line within it. An early return should of course produce an unreachable code error, as it would if the option to allow it wasn't turned on, but I'd expect this to otherwise be side-effect free, TypeScript doesn't seem to stop any other type checks just because the code is unreachable.
Related Issues:
There's a lot of narrowing-related issues so apologies if I happened to miss one, but I couldn't find anything quite related to this, as opposed to other types of narrowing issues.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.6.3 (also tested on nightly on playground)
Search Terms: unreachable code narrowing early return
Playground Link: Playground demonstration
Expected behavior:
If you uncomment the early return in the doAThing function (common temp change to disable some stuff for debugging), nothing should happen (allowUnreachableCode is enabled in playground options)
Actual behavior:
TypeScript now fails to perform the type-narrow from the if statement, causing a type error on the assignment line within it. An early return should of course produce an unreachable code error, as it would if the option to allow it wasn't turned on, but I'd expect this to otherwise be side-effect free, TypeScript doesn't seem to stop any other type checks just because the code is unreachable.
Related Issues:
There's a lot of narrowing-related issues so apologies if I happened to miss one, but I couldn't find anything quite related to this, as opposed to other types of narrowing issues.
The text was updated successfully, but these errors were encountered: