Closed
Description
π Search Terms
never type guard
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about type guarding
β― Playground Link
π» Code
function die(): never {
return null as never;
}
function inferDie() {
return die();
}
declare const x: string | null;
if (!x) {
inferDie();
}
x; // x is still possibly null
if (!x) {
die();
}
x; // x now can't be null
π Actual behavior
Two functions that have "identical" signatures, () => never
, are not acting the same
π Expected behavior
I'd expect both of these to act the same way since, for everything I can see, TS sees their signatures as being identical.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels