Closed
Description
π Search Terms
unreachable, reachability
π Version & Regression Information
- I test between versions 4.0.5 and 5.1.6
- I'm not sure whether this relates to Why doesn't awaiting a Promise<never> change reachability?Β #34955 (comment)
β― Playground Link
π» Code
const throwZero = () => { throw 0 };
function f0() {
throwZero();
console.log('expect unreachable');
}
function f1({ throw0 }: { throw0: typeof throwZero }) {
throw0();
console.log('expect unreachable');
}
declare function throwOne() : never;
function g0 () {
throwOne();
console.log('unreachable as expected');
}
function g1 ({ throw1 }: {throw1: typeof throwOne}) {
throw1();
console.log('expect unreachable');
}
π Actual behavior
In first code block:
The two console.log()
are not identified as unreachable code.
In second code block:
It works at g0
declaration but not g1
.
π Expected behavior
They should be unreachable code.
Metadata
Metadata
Assignees
Labels
No labels