I have this problem when trying to run in git bash. .switchMap is not geting executed and showing error as" error TS2339: Property 'switchMap' does not exist on type 'Observable' "
The code I am using is:
import { User } from './../classes/user';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable, of } from 'rxjs';
import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore';
import { from } from 'rxjs';
@Injectable()
export class AuthService {
public currentUser: Observable<User | null>;
constructor(
private router: Router,
private alertService: AlertService,
private afAuth: AngularFireAuth,
private db: AngularFirestore
) {
this.currentUser = this.afAuth.authState
.switchMap((user) => {
if (user) {
return this.db.doc<User>(`users/${user.uid}`).valueChanges();
} else {
return of(null);
}
});
}
my rxjs version is rxjs@6.3.3 latest and nodejs version is v8.12.0 please help I am building a chat website.