Exhaustiveness checking doesn't work with variables #12668
Labels
Suggestion
An idea for TypeScript
Too Complex
An issue which adding support for may be too complex for the value it adds
TypeScript Version: 2.1.1
If you have exhaustiveness checking where a result is a return from a function it works.
But if result is assigning value to a variable exhaustiveness checking basically does nothing.
Code
Expected behavior:
Function
area
: variablearia
should benumber
because the check is exhaustive.Sidenotes:
default
thentsc
believes that check is exhaustive.areaWrapped
uses IIFE to achieve the same effect and it works.Actual behavior:
Variable
area
is of typenumber | undefined
while it can't beundefined
.The text was updated successfully, but these errors were encountered: