title: Google closure-compiler complaining about undeclared variable in typeof call
body: <p>I am minifying JavaScript for a typical modern browser (eg. Chrome 64) using Google's closure-compiler v20180101. The same code compiled without errors for v20170409. I am using the same piece of JS in multiple a several different packaging contexts and would rather not split things into many tiny files.</p>
  
  <p>Instead, I've added some conditional code that uses <code>typeof</code> to see if some functions are already defined and if not, define them.</p>
  
  <p>This is a very basic example:</p>
  
  <pre><code>if (typeof foo === 'undefined') {
    foo = function() { return "Foo!"; }
  }
  </code></pre>
  
  <p>In response to this, clojure-compiler-v20180101 complains of:</p>
  
  <pre><code>foo.js: ERROR - variable foo is undeclared
  </code></pre>
  
  <p>I can add an extern file that declares <code>var foo</code>, but this seems to defeat the purpose of the <code>typeof</code> check. Also, in other situation <code>foo</code> gets declared twice which closure-compiler also complains about.</p>
  
  <p>Thanks in advance for any assistance.</p>