title: How to check if a variable exists in TypeScript?
body: <p>I have code that loops, and I want to initialize the variable one within the code. To do this, I check if the variable exists, and if not, initialize it.</p>
  <p>In JavaScript, I would normally just do the following<br></p>
  <pre><code>if (typeof variableExample === 'undefined') {
      // run this code
  }
  </code></pre>
  <p>But TypeScript doesn't like this. It tells me that it can't perform this because it cannot find the variable:<br>
  <a href="https://i.stack.imgur.com/yHfQr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHfQr.png" alt="" /></a></p>
  <p>Any ideas for getting around this?</p>