title: Typescript: how to get access to the navigator.connection property
body: <p>I would like to get access to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation" rel="nofollow noreferrer">NetworkInformation</a> interface using a simple TypeScript function like the following one:</p>
  
  <pre><code>private checkNetworkConnection(): void {
  const connection = Navigator.connection
    || navigator.mozConnection 
    || navigator.webkitConnection;
   const type = connection.type;
   console.log('CONNECTION TYPE: %o', type);
   console.log('DOWNLINK: %o', connection.downlink);
  }
  </code></pre>
  
  <p>The fact is that I keep getting back the <code>connection is undefined</code> error. Looking around on SO I found that the people that use Cordova extend the type definitions of Typescript importing <code>@types/cordova-plugin-network-information</code> but that doesn't solve my issue.</p>
  
  <p>A working StackBlitz example can be found <a href="https://stackblitz.com/edit/angular-ieaiw4?file=src%2Fapp%2Fapp.component.ts" rel="nofollow noreferrer">here</a>.</p>
  
  <ol>
  <li><a href="https://wicg.github.io/netinfo/#-dfn-connection-dfn-attribute" rel="nofollow noreferrer">https://wicg.github.io/netinfo/#-dfn-connection-dfn-attribute</a></li>
  <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API</a></li>
  </ol>