#If function returns true, parameter is not null?
4 messages · Page 1 of 1 (latest)
4 messages · Page 1 of 1 (latest)
How do I tell typescript that if a function returns true, parameter is not null?
e.g.
function biggerThanThree(x?: str) {
return str?.length > 3;
}
How to type this so that it knows that when biggerThanThree is true, x cannot be null.
!hb type predicates
Thank you!! It was on the tip of my tongue, and I couldn't think what it was called!