简体   繁体   中英

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10):

I am using angular material spinner in my project but , It shows this

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"D:/ControlCenter/ofservices/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig'.

I am getting this error :

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"D:/ControlCenter/ofservices/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig' `

Can anyone help me???

spinner.service.ts file

import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs/Rx';
export interface ISpinnerState {
  show: boolean
}

@Injectable()
export class SpinnerService {
  private _spinnerSubject = new Subject();

spinnerState = <Observable<ISpinnerState>>this._spinnerSubject.asObservable();
  show() {
    this._spinnerSubject.next(<ISpinnerState>{ show: true });
  }
  hide() {
    this._spinnerSubject.next(<ISpinnerState>{ show: false });
  }
}

spinner.component.ts

import {Component, OnDestroy, OnInit} from '@angular/core';
import { Subscription } from 'rxjs/Rx';
import {  ISpinnerState, SpinnerService } from './services/spinner.service';
@Component({
  selector: 'loading-spinner',
  template: `
  <div *ngIf="visible"
  class="spinner">
</div>
  `,
  styles: [`.spinner {position: absolute;left: 46%;top: 12%;background-color:black;width:50px;height:50px}`]
})

export class SpinnerComponent implements OnDestroy, OnInit {
  visible = false;

  private _spinnerStateChanged: Subscription;

  constructor(private _spinnerService: SpinnerService) { }

  ngOnInit() {
    this._spinnerStateChanged = this._spinnerService.spinnerState
      .subscribe((state: ISpinnerState) => this.visible = state.show);
  }
  ngOnDestroy() {
    this._spinnerStateChanged.unsubscribe();
  }
}

Try this version to see if it work for you

"rxjs": "6.3.3", 
"rxjs-compat": "6.3.3",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM