error TS2339: Property 'diagnostic' does not exist on type 'CordovaPlugins'
<p>I am using Ionic 2.</p>

<p>I followed <a href="https://stackoverflow.com/questions/33373967/ionic-display-error-if-gps-is-turned-off">this</a>, and did the following:</p>

<blockquote>
<pre><code>cordova plugin add cordova.plugins.diagnostic
npm install -g typings 
typings install dt~cordova --save --global
</code></pre>
</blockquote>

<p><strong>app.ts</strong></p>

<pre><code>    if (window.cordova &amp;&amp; cordova.plugins) {
      cordova.plugins.diagnostic.isLocationEnabled(function (enabled) {
        alert("Location is " + (enabled ? "enabled" : "disabled"));
      }, function (error) {
        alert("The following error occurred: " + error);
      });
    }
  }
</code></pre>

<p>I get the following error:</p>

<blockquote>
  <p><code>error TS2339: Property 'diagnostic' does not exist on type 'CordovaPlugins'.</code></p>
</blockquote>

<p>I notice that <code>window.cordova</code> is <code>undefined</code>.</p>

<p>If anyone can advise how I can get the Cordova Plugin working, I would appreciate it.</p>

<p>Thanks</p>