Closed
Description
Bug Report
π Search Terms
- return never
- unreachable code
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about return never & unreachable code
β― Playground Link
Playground link with relevant code
π» Code
declare const blue : (...args: any) => never
declare const hof: (fn :(a: (...args: any) => never) => void ) => void
const withBlue = ()=> {
blue("test")
return "OK" // Unreachable code detected
}
const withPink = (pink : (...args: any) => never)=> {
pink("test")
return "OK" // Unreachable code detected
}
const withGreen = (unk: unknown) => {
const green = unk as (...args: any) => never
green("test")
return "OK"// Unreachable code NOT detected
}
hof((self)=>{
self("nahh")
return "Ok" // Unreachable code NOT detected
})
π Actual behavior
When the function that returns never is inferred, it does not detect unreachable code
When the function that returns has been type-asserted, it does not detect unreachable code
π Expected behavior
Calling a function that returns never should render all code bellow unreachable