title: How to set a variable if undefined in typescript?
body: <p>I'm trying to set the variable value when it's undefined however, I'm getting an error while trying to use vanilla javascript approach. </p>
  
  <blockquote>
    <p>Block-scoped variable 'x' used before its declaration.</p>
  </blockquote>
  
  <p>What is the best approach when using typescript for setting undefined variable?</p>
  
  <pre><code>let x = (typeof x === 'undefined') ? def_val : x;
  </code></pre>