As I delve into the world of dynamic query documentation for AngularFireStore
, which can be found here, I encounter an issue. At the beginning stages, when setting up the BehaviorSubject in my constructor, a TypeScript error arises.
I understand that this is related to TypeScript strict mode, but as a newcomer, it's confusing. While disabling strict mode resolves the problem, I prefer not to take that route.
export class MembersSequencingComponent implements OnInit {
customers$ : Observable<Customer[]>; // utilizing a model instead of an interface
zoneFilters$: BehaviorSubject<Customer|null>;
constructor(afs: AngularFirestore) {
this.zoneFilters$ = new BehaviorSubject(null); >> //error occurs here
}
}
https://i.sstatic.net/MBLRC.png
Despite my efforts, TypeScript continues to flag an error.
Type 'BehaviorSubject<null>' is not assignable to type 'BehaviorSubject<Customer | null>'.
Types of property 'observers' are incompatible.
Type 'Observer<null>[]' is not assignable to type 'Observer<Customer | null>[]'.
Type 'Observer<null>' is not assignable to type 'Observer<Customer | null>'.
Type 'Customer | null' is not assignable to type 'null'.
Type 'Customer' is not assignable to type 'null'.ts(2322)
Customer Model
export class Customer {
customerNo: string;
customerAccountNo: string;
customerName: string;
}