TypeScript shows me below erros in app.component.ts:
Argument of type '(events: Event[]) => void' is not assignable to parameter of type '(value: Event[]) => void'.
Types of parameters 'events' and 'value' are incompatible.
Type 'Event[]' is not assignable to type 'import("/home/src/app/models/event.interface").Event[]'.
Type 'Event' is missing the following properties from type 'Event': _id, name, date
Here is my code:
event.interface.ts
export interface Event{
_id: string;
name: string;
date: Date;
}
app.service.ts
getEvents(): Observable<Event[]> {
return this.http.get<Event[]>('www.example.com/your-events')
}
app.component.ts
ngOnInit() {
this.appService.getEvents().subscribe(
(events: Event[]) => {
this.promotersEvents = events;
}
)
}
What is wrong with my code? Thanks for advice!