title: Using globalThis in Typescript
body: <p>I am trying to use globalThis in Typescript and I would like some suggestions on how to write it in a better way.<br>
  Current implementation is like this:</p>
  
  <p>Create a file <strong>types/global.d.ts</strong> and add inside</p>
  
  <pre><code>interface Global {
     foo: string
  }
  
  declare let foo: Global["foo"];
  </code></pre>
  
  <p>in <strong>tsconfig.json</strong> add </p>
  
  <pre><code>"files": [
    "types/global.d.ts"
  ]
  </code></pre>
  
  <p>Then in order to set the value of <code>foo</code> use</p>
  
  <pre><code>(globalThis as any).foo = "The value of foo"
  </code></pre>
  
  <p>What I don't like with this approach is first the boilerplate needed (but I think this cannot be avoided) and second the <code>(globalThis as any).foo =</code> expression</p>