I'm currently building a todo app with Angular 8 and using Firebase as the backend for my project.
In my todo service file, I encountered an error message that reads:
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();
}
}
This is how my interface is defined:
export interface ITodo {
task:string,
completed: boolean
}
If anyone has any insight into why I am encountering this error in my getTodo method, I would greatly appreciate it. Thank you!