Bug Report
๐ Search Terms
๐ Version & Regression Information
- Version: 5.0.4
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
never type and class
โฏ Playground Link
Playground link with relevant code
๐ป Code
function throwErrorFunction() : never {
throw new Error("Error in function")
}
class ErrorService {
throwErrorClass(): never {
throw new Error("Error in class")
}
}
function neverNotWorkingAsExpected() {
const errorService = new ErrorService();
errorService.throwErrorClass();
// The following line should be detected as unreachable
throwErrorFunction();
}
function neverWorkingAsExpected() {
throwErrorFunction();
// The following code is detected as unreachable
const errorService = new ErrorService();
errorService.throwErrorClass();
}
๐ Actual behavior
Code following a function of a class of type 'never' is not considered inaccessible.
It does not have the same behavior as a function that is not in a class.
๐ Expected behavior
The never type is correctly handled when used in a function of a class.
So after using the function, the following code is considered unreachable.
Bug Report
๐ Search Terms
๐ Version & Regression Information
nevertype and classโฏ Playground Link
Playground link with relevant code
๐ป Code
๐ Actual behavior
Code following a function of a class of type 'never' is not considered inaccessible.
It does not have the same behavior as a function that is not in a class.
๐ Expected behavior
The
nevertype is correctly handled when used in a function of a class.So after using the function, the following code is considered unreachable.