Here is the code snippet I have been working on:
return this.projectService.oneById(id).pipe(mergeMap(project => {
if (!project) {
return [];
}
const stories = this.getStories(id);
return combineLatest(project.members.map(member => {
return this.userService.one(member.id).pipe(map(memberData => {
const assigned = stories.pipe(mergeMap(t => combineLatest(t.filter(task => {
if (task && task.assignee?.id === member.id) {
return {
...task,
id: task.id
};
}
}))));
return {
id: member.id,
name: memberData?.displayName ?? 'Unknown',
assigned
};
}));
}));
}));
Unfortunately, I am encountering an issue where my function is expected to return Observable<Type[]>
, but it is currently providing
Observable<{ ...etc, object: Observable<Type[]> }
.
The core problem lies in the observable nested inside another observable. I have solved similar issues before in my code, but this one is proving to be quite challenging. I have tried various solutions without success.
I would greatly appreciate any assistance or guidance on resolving this matter.
PS: The specific warning message I am receiving is as follows:
Type 'Observable<{ id: string; name: string; assigned: Observable<[UserStory | undefined]>; }[]>' is not assignable to type 'Observable<Member[]>'. Type '{ id: string; name: string; assigned: Observable<[UserStory | undefined]>; }[]' is not assignable to type 'Member[]'. Type '{ id: string; name: string; assigned: Observable<[UserStory | undefined]>; }' is not assignable to type 'Member'. Types of property 'assigned' are incompatible. Type 'Observable<[UserStory | undefined]>' is missing the following properties from type 'UserStory[]': length, pop, push, concat, and 25 more.