Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript instanceof - Cannot find name

I have a problem with Typescript compilation. This code returns the error:

error TS2304: Cannot find name 'NavigationEnd'.

How can I make the compiler know about NavigationEnd type? NavigationEnd is angular2 router event type.

this.router.events.subscribe((e) => {e instanceof NavigationEnd ? 
console.log('NavigationEnd'):console.log('Not NavigationEnd')});

I`m using IDE PHPStorm.

like image 714
norweny Avatar asked Jul 04 '16 08:07

norweny


1 Answers

Seems you're missing an import

import { Router, NavigationEnd } from '@angular/router'
like image 59
Günter Zöchbauer Avatar answered Sep 21 '22 12:09

Günter Zöchbauer