属性'提升'在类型中无法分配给基本类型中的同一属性。

发布于 2025-01-31 11:52:25 字数 1305 浏览 4 评论 0 原文

我在 objection.d.ts 文件中遇到有关属性 lift 的错误,并且不确定如何纠正它。我正在使用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>;
}

I am getting this error about property lift in the Subject.d.ts file and not sure how to correct it. I am using RxJS version 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>;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我也只是我 2025-02-07 11:52:25

RXJS打字中的签名不正确,并得到在v5.4.2中: https://github.com/reactivex/ rxjs/pult/2722/files

因此,解决方案是为了更新为 代码>。

The signature in the RxJS's typings was incorrect and got fixed in v5.4.2: https://github.com/ReactiveX/rxjs/pull/2722/files.

The solution is therefore to update to [email protected].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文