Topic icon

Angular

0
After updating angular to the latest version, you might get this error:


Argument of type 'MonoTypeOperatorFunction<RouterEvent>' is not assignable to parameter of type 'OperatorFunction<Event_2, RouterEvent>'.
  Types of parameters 'source' and 'source' are incompatible.
    Type 'Observable<Event_2>' is not assignable to type 'Observable<RouterEvent>'.
      Type 'Event_2' is not assignable to type 'RouterEvent'.
        Type 'RouteConfigLoadStart' is missing the following properties from type 'RouterEvent': id, url

This error occurs at line where to subscribe to router events, that looks something like this:


this.routeSub = this.router.events
   .pipe(
    filter(
     (event: RouterEvent) => event instanceof NavigationStart
    ),
    tap(() => this.trigger.closePanel())
   )
   .subscribe();


Solution 1:
In recent version of angular, router.events emit a generic Event and not RouterEvent. Hence to correctly fix the issue import the Event from the angular/router module and replace RouterEvent with Event.

Here is how you do it:


import { NavigationStart, Router, Event} from "@angular/router";
this.routeSub = this.router.events
   .pipe(
    filter(
     (event: Event) => event instanceof NavigationStart
    ),
    tap(() => this.trigger.closePanel())
   )
   .subscribe();


Solution 2:
If you really don't care about explicit type(e.g. in the filter function above), just remove the RouterEvent type, and compiler will implicitly assign the Event type to it.
Wrote answer · 5/27/2023
Karma · 1435
0
This error started appearing in angular unit test after migrating to Angular 14.
As it's a null injector error we need to provide the UntypedFormBuilder in the TestBed.configureTestingModule, 

You can update your TestBed.configureTestingModule like this:


// Update: import UntypedFormBuilder
import { UntypedFormBuilder } from "@angular/forms";

... // your other code

// configureTestingModule block

const formBuilderStub = () => ({});
const untypedFormBuilderStub = () => ({}); // This is the updated code
TestBed.configureTestingModule({
   schemas: [NO_ERRORS_SCHEMA],
   declarations: [FormComponent],
   providers: [{ provide: FormBuilder, useFactory: formBuilderStub },
                     {provide: UntypedFormBuilder, useFactory: untypedFormBuilderStub} // This is the updated code
], 
  }).compileComponents();

Wrote answer · 7/9/2022
Karma · 1435
0

No, a square matrix A is not invertible if its determinant |A| is equal to 0. A matrix is invertible (also known as non-singular or non-degenerate) if and only if its determinant is non-zero. If the determinant is zero, the matrix is singular and does not have an inverse.

Invertibility requires that the matrix represents a transformation that can be "undone." When the determinant is zero, it means the matrix collapses space (or at least reduces its dimension), making it impossible to reverse the transformation uniquely.

You can explore more about invertible matrices and their properties on websites such as:

Wrote answer · 3/14/2025
Karma · 40