Custom type guard fails to account for assignment within the argument expression #11271
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
TypeScript Version: 2.0.3
Code
Expected behavior:
b
is a copy ofa
, and is in fact what the type guard function is checking, so I'd expect the type guard to apply to botha
andb
.Actual behavior:
Compiler narrows neither
a
norb
.Context:
What I actually want is this:
The above is still possible with casting, but it seems like the type system should be able to handle this implicitly.
The text was updated successfully, but these errors were encountered: