title: Typescript jest global variable example
body: <p>It is the same question, as correctly answered here <a href="https://stackoverflow.com/questions/38060295/jest-global-variable-example">jest global variable example</a> , but the concern is Typescript.</p>
  <pre><code>console.log(__DEV__);
  </code></pre>
  <p>Results in:</p>
  <pre class="lang-none prettyprint-override"><code>error TS2304: Cannot find name __DEV__.
  </code></pre>
  <p>The global var <code>__DEV__</code> is defined in package.json as:</p>
  <pre><code>  &quot;jest&quot;: {
      &quot;globals&quot;: {
        &quot;__DEV__&quot;: true
      }
    }
  </code></pre>
  <p>Has anybody a solution or work around?</p>
  <p>Relevant jest documentation: <a href="https://jestjs.io/docs/en/next/configuration#globals-object" rel="nofollow noreferrer">https://jestjs.io/docs/en/next/configuration#globals-object</a></p>