DEV Community

Discussion on: Create a Simple Breadcrumb in Angular

Collapse
 
hachirsara2020 profile image
hachirsara2020

thank you for this tuto .
but I getting thir error and I don't know how resolve it:
Types of parameters 'source' and 'source' are incompatible.
Type 'import("C:/Users/asus/breadcrumb/node_modules/rxjs/internal/Observable").Observable' is not assignable to
type 'import("C:/Users/asus/breadcrumb/node_modules/rxjs/internal/Observable").Observable'.
Type 'import("C:/Users/asus/breadcrumb/node_modules/@angular/router/router").Event' is not assignable to type 'Event'.
Type 'ActivationEnd' is missing the following properties from type 'Event': bubbles, cancelBubble, cancelable, composed, and 18 more.

24         filter((event: Event) => event instanceof NavigationEnd),
Enter fullscreen mode Exit fullscreen mode
Collapse
 
zhiyueyi profile image
Zhiyue Yi

It could be different rxjs version. When I wrote this article, I used rxjs 5.5.6 version.

Collapse
 
larsvonqualen profile image
Lars von Qualen

Either import the generic event from @angular/router:

import { Router, ActivatedRoute, NavigationEnd, Event } from '@angular/router';
Enter fullscreen mode Exit fullscreen mode

or change the filter to infer the type automatically:

filter(event => event instanceof NavigationEnd),
Enter fullscreen mode Exit fullscreen mode
Collapse
 
paco_ita profile image
Francesco Leardini • Edited

Using RxJS (6.6.3) and ESLint (7.10.0 with default rules) the code above fails: