You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{assertExists,assertGreater,assertAlmostEquals,assertLess}from'@std/assert';constx=Math.random()>0.5 ? 10 : undefined;consty=Math.random()>0.5 ? 10 : undefined;constz=Math.random()>0.5 ? 10 : undefined;constt=Math.random()>0.5 ? 10 : undefined;assertExists(x);console.log(x+1);// no warning, because assertExists did type narrowingassertGreater(y,0);assertLess(z,20);// no complaints about z being "possibly undefined"console.log(x-y-z-t);// y, z, t are "possibly undefined", but x is not
Expected behavior
All asserts, not just assertExists, should narrow undefined out of the type if the assertion passes. That includes (not pictured here) assertGreaterOrEqual etc.
Environment
deno version: 2.1.3
std version: 1.0.9
The text was updated successfully, but these errors were encountered:
Another note: #6245 is a breaking change to nullable input in the current form. We currently don't have plan to make major upgrade to std packages in the near future.
Steps to Reproduce
Expected behavior
All asserts, not just
assertExists
, should narrowundefined
out of the type if the assertion passes. That includes (not pictured here)assertGreaterOrEqual
etc.Environment
The text was updated successfully, but these errors were encountered: