title: Why can't TypeScript assert that a chain of nullable values is all non-null at the same time?
body: <p>I have a chain of nullable values that I'd like to assert is non-null in a single line.</p>
  <p>It seems to me that if TS knows that <code>availablePackages</code> is non-null then the whole chain is definitely non-null.  But I still get an error if I write further code assuming <code>offerings</code> is non-null here.  Is that expected behavior somehow?  the <code>offerings</code> reference could not have changed in the meantime and it had to be non-null for the previous call to work.</p>
  <pre><code>export function hasValue&lt;T&gt;(value: T): value is NonNullable&lt;T&gt; {
    return value !== undefined &amp;&amp; value !== null;
  }
  
  // ...
  
  if (!hasValue(offerings?.current?.availablePackages)) {
    return;
  }
  
  offerings.current.availablePackages.length &lt; 1; // ERROR, offerings may be null
  </code></pre>