title: Declaring a global variable in Angular 6 / Typescript
body: <p>I have two files, <code>'Drawer.ts'</code> and the <code>'sidenav-open-close.component.ts'</code> componenet.</p>
  
  <p>I need a variable to be shared between these two, with the option to change it's value in <code>'Drawer.ts'</code>, and <code>'sidenav-open-close.component.ts'</code> will act accordingly.</p>
  
  <p>I tried using this method - 
  <a href="https://stackoverflow.com/questions/36158848/what-is-the-best-way-to-declare-a-global-variable-in-angular-2-typescript/36183988">What is the best way to declare a global variable in Angular 2 / Typescript</a>
  and created a file named globals.ts with these conntent:</p>
  
  <pre><code>'use strict';
  export var diffMode : boolean = false;
  </code></pre>
  
  <p>and imported it in both files with <code>import * as myGlobals from './src/globals.ts';</code></p>
  
  <p>I managed to read diffMode, but when trying to set it through <code>'Drawer.ts'</code> i get the following error:</p>
  
  <pre><code>ERROR TypeError: Cannot set property diffMode of [object Object] which has 
  only a getter
  </code></pre>
  
  <p>Help will be appreciated, Thanks.</p>