'Typescript Strict Mode: having error on BehaviouralSubject (null)
I'm trying to follow the documentation on dynamic query from the AngularFireStore documentation,
here
I'm just starting and upon typing the behaviourSubject on my constructor.
I know this is just a typescript rule matter, but I am new and also confused what's wrong here. Disabling strict mode does it but I don't want to do that.
export class MembersSequencingComponent implements OnInit {
customers$ : Observable<Customer[]>; // instead of using an interface I've used a model
zoneFilters$: BehaviorSubject<Customer|null>;
constructor(afs: AngularFirestore) {
this.zoneFilters$ = new BehaviorSubject(null); >> //typescript error happens here
}
}
However, my typescript is giving me 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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

