-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
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
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created