I have the following resolver class
export class UserResolverService implements Resolve<Observable<IUserAccount[] | IUserMoreInfo>>{
constructor(
private userService: UserService,
private router: Router
){}
resolve(route: ActivatedRouteSnapshot): Observable<IUserAccount[] | IUserMoreInfo> {
.......
.........
return this.userService.getUserAccounts(.....).pipe(
take(1),
map((res) => {
console.log('Data', res);
const data = res.data;
const moreInfo = res.moreInfo;
return {data, moreInfo};
})
.......
........
}
}
For the above TS complains with following error, but when I return back the data with res.data the error disappears.
Type '{ data: IUserAccount[]; moreInfo: IUserMoreInfo | undefined; }' is missing the following properties from type 'IUserAccount[]': length, pop, push, concat, and 26 more.ts(2322)
The function that makes the request
public getUserAccounts = (....): Observable<IUserAccounts> => {
return this.http.get<IUserAccounts>(`${url}`);
};
My interface definitions are as following
export interface IUserAccounts {
data: IUserAccount[];
moreInfo?: IUserMoreInfo;
}
export interface IUserAccount{
name: string
......
.....
}
export interface IUserMoreInfo{
alias: string
.....
......
}