Error TS2339: 'Connection' property does not exist on type 'Browser'

advertisements

very simple issue

I am trying ang 2 and ionic 2.

Used following code -

main file -

/// <reference path="../../../node_modules/@angular/platform-browser/src/browser.d.ts" />

import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';
import {NavController} from 'ionic-angular';
import {Network} from 'ionic-native'

@Component({
  templateUrl: 'build/pages/items-map/items-map.html'
})
export class ItemsMap {

  constructor(private platform : Platform) {
    console.log(navigator.Connection);
  }

}

NOw whenever I build the project using gulp build, i get -

Error TS2339: Property 'Connection' does not exist on type 'Navigator'.

Any help on same? I know there are some more similar issues logged, but none of the are having any definitive answers


This is TypeScript Definition problem. It need TypeScript definition for the plugin. Use npm to install it.

npm install @types/cordova-plugin-network-information --save

If it doesn't work, try Network.type instead of navigator.connection.