My code compiles and everything is working fine, but my IDE (Visual Studio Code) shows the following error message and I'm unable to deploy my app (with ng build --prod):
ERROR in src/app/training/training.service.ts(61,46): error TS2339: Property 'name' does not exist on type '{}'. src/app/training/training.service.ts(62,50): error TS2339: Property 'duration' does not exist on type '{}'. src/app/training/training.service.ts(63,50): error TS2339: Property 'calories' does not exist on type '{}'.
I import the map operator like this:
import { map, take } from 'rxjs/operators';
and use it like this:
...
.snapshotChanges()
.pipe(
map(docArray => {
return docArray.map(doc => {
return {
id: doc.payload.doc.id,
name: doc.payload.doc.data().name,
duration: doc.payload.doc.data().duration,
calories: doc.payload.doc.data().calories
};
});
})
)
...
My interface looks like:
export interface Exercise {
id: string;
name: string;
duration: number;
calories: number;
date?: Date;
state?: 'completed' | 'cancelled' | null;
}
What am I doing wrong?