title: Why get error `s is not defined` when excute javascript
body: <p>I have the following code in my typescript file (also a compiled javascript file):
  s here is a global variable from external javascript file.</p>
  
  <pre><code>declare var s: any;
  function setValue() {
      if (s) {
          s.value = 'authenticated';
      }
  }
  </code></pre>
  
  <p>But when excute it will throw </p>
  
  <blockquote>
    <p>error: Uncaught ReferenceError: s is not defined.</p>
  </blockquote>
  
  <p>Need to change to <code>if (typeof s !== 'undefined')</code>. But I remember <code>if(s)</code> should also work. Anyone knows why?</p>
  
  <p>If I do:</p>
  
  <pre><code>    function setValue() {
      let s;
        if (s) {
          s.value = 'authenticated';
        }
      }
  </code></pre>
  
  <p>It's working fine. But s here is also undfined.</p>