Типизация не проходит компиляцию
//Property 'userId' does not exist on type 'ICustomer | IMultiResult<ICustomer>
оно же есть в ICustomer не пойму что не так
interface IMultiResult<T> {
result: T[];
totalCount: number;
}
interface IResponse<T> {
body: T | IMultiResult<T>;
status: keyof typeof EResponseStatus;
errorCode: keyof typeof EErrorCodes;
}
export type TResponse<T> = Promise<IResponse<T>>;
export interface ICustomer {
id: string;
userId: string;
addressId: string;
}
export class CustomerService {
static getCustomerById(id: string): TResponse<ICustomer> {
return fetch(URLS.CUSTOMER.ID(id)).then(res => res.json());
}
}
const { body: {userId, addressId} } = await CustomerService.getCustomerById(id);