Z
Z
zlodiak2019-06-20 13:32:32
Angular
zlodiak, 2019-06-20 13:32:32

How to fix typing?

On the stackblitz service, I wrote the simplest service that receives an array of users.
LIVE DEMO
Everything is ok, everything works. But after I export the project from this service and run it on my laptop, the following errors appear in the console:

ERROR in src/app/app.component.ts(22,9): error TS2322: Type 'Placeholder' is not assignable to type 'Placeholder[]'.
  Property 'length' is missing in type 'Placeholder'.
src/app/data.service.ts(16,5): error TS2322: Type 'Observable<Object>' is not assignable to type 'Observable<Placeholder>'.
  Type 'Object' is not assignable to type 'Placeholder'.
    The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
      Property 'id' is missing in type 'Object'.

Please tell me what needs to be corrected so that they do not exist

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-20
@zlodiak

getHttpData(): Observable<Placeholder[]> {
  return this.httpClient.get<Placeholder[]>(this.httpDataUrl);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question