I have a piece of code that retrieves data from the backend server.
Here is the code snippet:
@Injectable()
export class DictionariesDatasourceFacadeService {
public invoiceTemplate: IDataSource<IComboboxItem>;
public replacedLegalEntity: IDataSource<IComboboxItem>;
public salesOrderTemplate: IDataSource<IComboboxItem>;
public deliveryNoteTemplate: IDataSource<IComboboxItem>;
public createInvoiceAction: IDataSource<IComboboxItem>;
public clientPortal: IDataSource<IComboboxItem>;
private readonly dataSourceFactory = inject(DataSourceFactory);
private readonly invoiceTemplateService = inject(InvoiceTemplateService);
private readonly replacedLegalEntityService = inject(LegalEntityService);
private readonly salesOrderTemplateService = inject(SalesOrderTemplateService);
private readonly createInvoiceActionService = inject(CreateInvoiceActionService);
private readonly deliveryNoteTemplateService = inject(DeliveryNoteTemplateService);
private readonly clientPortalService = inject(ClientPortalService);
public constructor() {
this.init();
}
private init(): void {
this.invoiceTemplate = this.createGenericDataSource(this.invoiceTemplateService.getSimpleInvoiceTemplates());
this.replacedLegalEntity = this.createGenericDataSource(this.replacedLegalEntityService.getSimpleLegalEntities());
this.salesOrderTemplate = this.createGenericDataSource(
this.salesOrderTemplateService.getSimpleSalesOrderTemplates()
);
this.deliveryNoteTemplate = this.createGenericDataSource(
this.deliveryNoteTemplateService.getSimpleDeliveryNoteTemplates()
);
this.createInvoiceAction = this.createGenericDataSource(
this.createInvoiceActionService.getAlgorithms()
);
this.clientPortal = this.createGenericDataSource(this.clientPortalService.getActiveClientPortals());
}
private createGenericDataSource<T extends IComboboxItem>(method: Observable<T[]>): IDataSource<IComboboxItem> {
return this.dataSourceFactory.createLocalDataSource(
() => method.pipe(map(x => x.sort(sortByName))),
filterByNameFn
);
}
}
I encountered errors on the line
this.createInvoiceActionService.getAlgorithms()
.
https://i.sstatic.net/jtWDzxeF.png
However, I don't see any any
type errors.
Here is the code snippet for the getAlgorithms
method:
@Injectable({
providedIn: 'root'
})
export class CreateInvoiceActionService extends BaseHttpService {
constructor(http: HttpClient) {
super(getBasePath('app', '/api/v1/CreateInvoiceAction'), http);
}
public getAlgorithms(): Observable<$models.CreateInvoiceActionSimpleDTO[]> {
return this.post<$models.ICreateInvoiceActionSimpleDTO[]>(
`GetAlgorithms`,
).pipe($mappers.mapCollection($models.CreateInvoiceActionSimpleDTO));
}
}
For example, there are no errors when accessing the following line:
this.deliveryNoteTemplate = this.createGenericDataSource(
this.deliveryNoteTemplateService.getSimpleDeliveryNoteTemplates()
);
Here is the generated code:
https://i.sstatic.net/pn9acIfg.png
How can I resolve this error?