-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
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
holtwick
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed