Closed
Description
Bug Report
π Search Terms
return never instance method unreachable code
π Version & Regression Information
Saw this first on version 4.4.4, confirmed still exists in 4.7.4
β― Playground Link
π» Code
function throws(): never {
throw new Error()
}
function testUnreachable1() {
throws();
// ts flags this as unreachable
console.log("is unreachable!")
}
class TestClass {
throws(): never {
throw new Error()
}
}
const TestClassInstance = new TestClass()
function testUnreachable2() {
TestClassInstance.throws();
// >>>>> ts **does not** flag this as unreachable
console.log("should be unreachable :(")
}
π Actual behavior
Unlike a stand-alone function, instance methods which return never
don't mark the following lines in the block as unreachable code
π Expected behavior
Similar to a stand-alone function, instance methods which return never
should mark the following lines in the block as unreachable code