I am using Angular 8 to make a todo app with a firebase backend.
This is my todo service file which contains the error stating:
Type `Observable unknown[]` is not assignable to type `Observable ITodo[]`.
Type `unknown[]` is not assignable to type `ITodo[]`.
Type `{}` is missing the following properties from type `ITodo`: task, completed
import { AngularFireDatabase } from '@angular/fire/database';
import { Observable } from 'rxjs';
import { ITodo } from './models/todo';
@Injectable({
providedIn: 'root'
})
export class TodosService {
constructor(private db: AngularFireDatabase) { }
createTodo() {
return this.db.list('Todos').push({
task: 'clean',
completed: 'false'
});
}
getTodo(): Observable<ITodo[]>{
return this.db.list('Todos').valueChanges();
}
}
My interface looks like this:
export interface ITodo {
task:string,
completed: boolean
}
Does any one have an idea why I am getting that error? Thanks note: the error is on my getTodo method.
{}is missing the following properties from typeITodo: task, completed". It looks like the items returned by valueChanges() do not hold any data. Have you made sure that the data returned by valueChanges() has the fields "task" and "completed"?this.db.list<ITodo>('Todos').valueChanges()