rxjs
rxjs copied to clipboard
Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
Bug Report
[app-scripts] [13:12:47] typescript: node_modules/ionic-native/node_modules/rxjs/Subject.d.ts, line: 16
[app-scripts] Class 'Subject<T>' incorrectly extends base class 'Observable<T>'. Types of property 'lift' are
[app-scripts] incompatible. Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator:
[app-scripts] Operator<T, R>) => Observable<R>'. Type 'Observable<T>' is not assignable to type 'Observable<R>'. Type 'T'
[app-scripts] is not assignable to type 'R'.
[app-scripts] L16: export declare class Subject<T> extends Observable<T> implements ISubscription {
[app-scripts] L17: observers: Observer<T>[];
Current Behavior Throws this error on first Ionic Build then the error goea
Code I'm working
getProducts(): Observable<Product[]> {
const cached = window.localStorage.getItem('products_json')
const productsObservable = this.http.get<Product[]>(this.url)
if (cached) {
// use cached for instant response
productsObservable.subscribe( (products:Product[]) => {
// on data update localstorage
window.localStorage.setItem('products_json', JSON.stringify(products, null, 2))
}, ((err) => {
this.toast("No se han podido actualizar los datos del servidor. Intente mas tarde")
})
)
// return cached information
return of(JSON.parse(cached))
} else {
//fetch the data from server
productsObservable.subscribe((products : Product[]) => {
// store on localstorage
window.localStorage.setItem('products_json', JSON.stringify(products, null, 2))
}, (err) => {
this.toast("No se han podido actualizar los datos del servidor. Intente mas tarde")
})
return productsObservable
}
}
}
Environment- Runtime: [e.g. Node v${8.10.0}, Chrome v${68.0.3440.106}] "rxjs": "5.5.11", angular/common": "5.2.11", "typescript": "~2.6.2"
I believe this is probably dupe of https://github.com/ReactiveX/rxjs/issues/3281#issuecomment-362032012.
Please check above suggestions, if it still appears please file new issue with reproducible code.