I made this code:
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
};
}));
}));
}));
But I'm having a problem because my function expects to return Observable<Type[]>, but it is currently returning Observable<{ ...etc, object: Observable<Type[]> }.
Obviously the problem is the observable inside the observable. I am, however, unsure how to fix this in this case. I have solved this many times in my current code, but this one is hard for me to understand because whatever I try nothing changes.
Thank you for helping in advance.
PS: the exact warning is this:
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.
Memberinterface code? According the error your method returns data in other type thanMember[].