While working with an Angular 14+ application, if you have configured any link something similar to this

<a routerLink="/user" queryParams="{ userName: 'John_Doe', id:123  }"> User </a>

then, you may come across an error saying Type ‘string’ is not assignable to type ‘Params’ .

The reason for the error is, the queryParams accepts a value which is of type Params which is defined like this in Angular

type Params = {
    [key: string]: any;

Since, we are simply passing a string instead of the required data type, we are getting the error Type ‘string’ is not assignable to type ‘Params’.

How to Solve Type ‘string’ is not assignable to type ‘Params’ error

The solution for the error is straight forward, that is, we need to do property binding on the queryParams property like this

<a routerLink="/user" [queryParams]="{ userName: 'John_Doe', id:123  }"> User </a>