Understand Node's assert()
as a type guard
#19622
Labels
Duplicate
An existing issue was already created
assert()
as a type guard
#19622
TypeScript Version: 2.5.3
Code
For code like below:
, typescript understand that
a
is non-null when returned fromgetFoo()
.But Node.js has its own
assert
module, and it is not understood by typescript and we need a type-cast like below:It'd be really great if typescript understands that the non-nullness has been already checked by the
assert()
call anda
is non-null in this case.The text was updated successfully, but these errors were encountered: