title: How to declare a variable that may not exist in typescript?
body: <p>I have a angular app and I need to use the <code>chrome</code> extension object in my app.
  So i did in my component:</p>
  
  <pre><code>declare var chrome: any;
  
  @Component({
  templateUrl: './myComponent.component.html'
  })
  export class MyComponent implements AfterViewInit {
  
     ngAfterViewInit(): void {
  
        if(chrome) 
            //some code
     }
  
  }
  </code></pre>
  
  <p>If im using this code on <code>Google Chrome browser</code> it works fine, I do have access to the <code>chrome</code> object. </p>
  
  <p>The problem is when Im using other browser like <code>Firefox</code>, the console throws an error:</p>
  
  <blockquote>
    <p>ReferenceError: chrome is not defined</p>
  </blockquote>
  
  <p>It seems the typescript does not "declare" the variable chrome if the object does not exist. So I would like to know how to deal with this? </p>
  
  <p>Thanks!</p>