title: How can I conditionally import/export libraries in TypeScript?
body: <p>I have a file that I want to be able to use both on the server using node.js as well as on the  browser.</p>
  
  <p>I conditionally imported an external library using this line. On the browser, I assume that XRegExp is already defined.</p>
  
  <pre class="lang-default prettyprint-override"><code>if (typeof require !== 'undefined') XRegExp = require('xregexp').XRegExp;
  </code></pre>
  
  <p>and I conditionally exported the code using this line</p>
  
  <pre class="lang-default prettyprint-override"><code>if (typeof module !== 'undefined' &amp;&amp; !module.exports) module.exports = ret;
  </code></pre>
  
  <p>How can I do the same thing in TypeScript without the compiler complaining?</p>