Closed
Description
π Search Terms
Never, return type never
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
let a: string | undefined
let b: string | undefined
let c: string | undefined
const af = () => {
throw new Error()
}
const bf = (): never => {
throw new Error()
}
const cf: () => never = () => {
throw new Error()
}
if (!a) af();
a.length // Error
if (!b) bf();
b.length // Error
if (!c) cf();
c.length // Fine
π Actual behavior
Typescript does not check 'never' in condition statements but does if the whole function is declared
π Expected behavior
The 'never' return type should always behave in the same way
Additional information about the issue
No response