Angular, HttpClient; 属性 '.shareReplay' 在类型 'Observable' 上不存在

Angular, HttpClient; Property '.shareReplay' does not exist on type 'Observable'

抱歉,如果这是一个显而易见的问题。 我正在学习本教程:https://blog.angular-university.io/angular-jwt-authentication/

我像教程中那样创建了服务,但它告诉我 属性 '.shareReplay' 在类型 'Observable' 上不存在,我想我的导入不正确,但我不能似乎找到了正确的。

import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {User} from "./model/user";

@Injectable({
  providedIn: 'root'
})
export class AuthenticationService {

  constructor(private http: HttpClient) {
  }

  login(username: string, password: string){
    return this.http.post<User>('/login', {username, password})
      .shareReplay();
  }
}

这在 rxjs v5 之前是有效的,但现在您需要使用如下所示的 pipable 运算符

import {shareReplay } from 'rxjs/operators'



login(username: string, password: string){
    return this.http.post<Body>('/login', {username, password}).pipe(
      shareReplay()
    )
      
  }