我收到有關檔案中屬性lift的此錯誤Subject.d.ts,不知道如何更正。我正在使用 RxJS 版本 5.0.1。
Error TS2416 (TS) Property 'lift' in type 'Subject<T>' is not assignable to the same property in base type 'Observable<T>'.
Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
Type 'Observable<T>' is not assignable to type 'Observable<R>'.
Type 'T' is not assignable to type 'R'.
'R' could be instantiated with an arbitrary type which could be unrelated to 'T'.
/**
* @class Subject<T>
*/
export declare class Subject<T> extends Observable<T> implements ISubscription {
observers: Observer<T>[];
closed: boolean;
isStopped: boolean;
hasError: boolean;
thrownError: any;
constructor();
static create: Function;
lift<R>(operator: Operator<T, R>): Observable<T>;
next(value?: T): void;
error(err: any): void;
complete(): void;
unsubscribe(): void;
protected _subscribe(subscriber: Subscriber<T>): Subscription;
asObservable(): Observable<T>;
}
uj5u.com熱心網友回復:
RxJS 型別中的簽名不正確,并在 v5.4.2 中得到修復:https ://github.com/ReactiveX/rxjs/pull/2722/files 。
因此解決方案是更新到[email protected].
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/481033.html
標籤:有角度的 打字稿 rxjs rxjs-observables
上一篇:使用打字稿從物件陣列創建物件
