title: Argument of type 'null' is not assignable to parameter Angular
body: <pre><code>@Injectable({ providedIn: 'root' })
  export class AuthenticationService {
      private currentUserSubject: BehaviorSubject&lt;User&gt;;
      public currentUser: Observable&lt;User&gt;;
  
      constructor(private http: HttpClient) {
          this.currentUserSubject = new BehaviorSubject&lt;User&gt;(JSON.parse(localStorage.getItem('currentUser')));
          this.currentUser = this.currentUserSubject.asObservable();
      }
  
      public get currentUserValue(): User {
          return this.currentUserSubject.value;
      }
  
      login(username: string, password: string) {
          return this.http.post&lt;any&gt;(`${environment.apiUrl}/users/authenticate`, { username, password })
              .pipe(map(user =&gt; {
                  // store user details and jwt token in local storage to keep user logged in between page refreshes
                  localStorage.setItem('currentUser', JSON.stringify(user));
                  this.currentUserSubject.next(user);
                  return user;
              }));
      }
  
      logout() {
          // remove user from local storage to log user out
          localStorage.removeItem('currentUser');
          this.currentUserSubject.next(null);
      }
  }
  </code></pre>
  <p>Any idea why am i getting error at the last line(<strong>this.currentUserSubject.next(null)</strong>)?
  Error message: <strong>Argument of type 'null' is not assignable to parameter of type 'User'.</strong>
  The latest typescript version does not allow this? What would be another solution?</p>