title: How to detect correct type for a variable in Typescript when types are conditional
body: <p>The code is like this:</p>
  
  <pre><code>class MyClass {
    getValue() {
      // some code here...
    }
  }
  
  const IS_ENABLED = process.env.IS_ENABLED || false;
  const myClass = IS_ENABLED ? new MyClass() : null;
  
  function getValue() {
    if (!IS_ENABLED) return false;
  
    return myClass.getValue();
  }
  </code></pre>
  
  <p>Now at this point, TypeScript is giving error (for myClass.getValue()):</p>
  
  <pre><code>Object is possibly 'null'.
  </code></pre>
  
  <p>But, since I've checked the condition, I'm sure it's not null.</p>
  
  <p>Is there any way for TypeScript to handle it?</p>