Menu

Problems with subscribe

Reddit r/angular·u/Putrid-Bookkeeper968·3 days ago
#pSANmZT4
#error#type#people#code#state
Reading 0:00
15s threshold

Hello everybody

I have the following problem with subscribe. My code looks like:

this.personSercice.getPeople().pipe( takeUntilDestroyed(this.destroyRef) ).subscribe({ next: (people) => this.state.update(() => ({ ...this.state(), loading: false, people })), error: (error) => { console.log(error); this.setError(error); } }); Parameter 'people' implicitly has an 'any' type, but a better type may be infered from usage. and Parameter 'error' implicitly has an 'any' type, but a better type may be infered from usage. When I change the code to: error: (error: any) the error dissappears, but I do not understand why... When I try the same with the first error, changing the code to: next: (people: PersonModel) => this.state.update(() => ({ ...this.state(), loading: false, people })), The error is: The type 'PersonModel' is missing the following properties from type 'readonly PersonModel[]length, concat, join, slice... Please let me know if more code is required. Can somebody explain my why???.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.