So if by any chance you have an idea it would be greatly appreciated, otherwise I will try to debug this again when going back from vacations (type error):
Here is my app.components.ts file
import { Observable } from './../../node_modules/@firebase/util/dist/node-esm/src/subscribe.d';
import { Component } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/compat/database';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
author$: any;
constructor(db: AngularFireDatabase) {
this.author$ = db.object('/authors/1').valueChanges();
}
}
and my app.component.html one:
<ul *ngIf="author$ | async as author">
<li>{{ author.name }}</li>
<li>{{ author.students }}</li>
<li>{{ author.isPremium }}</li>
</ul>
In this configuration, I have this error for each author.*
Error: src/app/app.component.html:17:17 - error TS2571: Object is of type 'unknown'.
17 <li>{{ author.isPremium }}</li>
~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
Hmm, might be the return type of author$ that is wrong, so I then replaced
author$: any;
with
author$: Observable<any>;
as suggested in angular - Getting error "TS2571: Object is of type 'unknown'" when trying to display object properties from a Firebase observable - Stack Overflow
But still I have a type error (translated from french)
Impossible to assign type 'Observable<unknown>' to type 'Observable<any>'.
Types of 'subscribe' property are incompatibles.
Also tried with Observable and an even worse error happened (my local Observable subscribe method is different from db.object.valueChanges() one)
If you have any ressource which could help or could teach me with a relevant ressource how to debug such things, itâd be greatly appreciated ^^
Young student here still having a lot to learn!