I have a snippet of code (slightly simplified) that is functioning correctly and the console logs are displaying everything properly, with valid parameters passed:
return observable.pipe(map(response => ({ response, param2, param3, param4, param5 })));
}),
tap(({ response }) => {
if (this.hasNotifications(response?.notif)) {
//do something
}
}),
filter(({ response }) => !this.hasNotifications(response?.notif)),
switchMap(({ response, param2, param3, param4, param5 }) => {
console.log('and even here');
console.log(response);
console.log(param2);
console.log(param3);
console.log(param4);
console.log(param5);
However, if I remove
tap(() => console.log('we are here')),
which was only inserted for development purposes, I encounter compilation errors:
error TS2339: Property 'param2' does not exist on type '{ response: any; }'.
305 switchMap(({ response, param2, param3, param4, param5 }) => {
The same issue arises for param3, param4, and param5.
Do you have any insight into why these errors have appeared and how they can be rectified while still correctly passing the parameters?