I have the following expressions:
This fetches the ID parameter passed through the URL:
editUserId = this.route.snapshot.paramMap.get('id');
Then i used FindIndex on an array of objects to find the index of an element in the array equal to the above mentioned ID value fetched from the URL:
this.userToUpdate = this.allUsers.findIndex((x: any) => x.UserId === this.editUserId);
(this.allUsers) being my array of objects.
Although the findIndex continuously returns the value -1 .. I have tried the following two methods, both of which return the same error: "This condition will always return 'false' since the types 'number' and 'string | null' have no overlap":
this.userToUpdate = this.allUsers.findIndex((x: any) => parseInt(x.UserId) === this.editUserId);
this.userToUpdate = this.allUsers.findIndex((x: any) => Number(x.UserId) === this.editUserId);
Any reason as to why this may be happening?