构建我的JHipster Angular项目时收到此错误。它发生在命令yarn start
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Subscription } from 'rxjs/Subscription';
import { JhiEventManager, JhiParseLinks, JhiAlertService } from 'ng-jhipster';
import { ITEMS_PER_PAGE, Principal } from '../../shared';
import { Observable } from 'rxjs/Observable';
....
private subscription: Subscription;
private eventSubscriber: Subscription;
...
ngOnInit() {
this.subscription = this.route.params.subscribe((params) => {
this.load(params['id']);
});
}
> TS90010: Type 'Subscription' is not assignable to type 'Subscription'.
> Two different types with this name exist, but they are unrelated.
但是它以前没有问题。我不知道为什么会这样。
答案 0 :(得分:0)
尝试更改这些行
import { Subscription, Observable } from 'rxjs';
对此
.groupby
答案 1 :(得分:0)
不是直接回答您的问题,而是使用一个Subject来记录所有订阅对象,而不是跟踪所有带有订阅对象的订阅。这是在Angular中管理rxjs订阅的推荐方法。
finalise = new Subject<void>();
this.route.params.subscribe((params) => {
this.load(params['id']);
}).pipe(takeUntil(this.finalise)); // No need to unsubscribe if finalise emits.
ngOnDestroy() {
this.finalise.next();
this.finalise.complete();
}
现在,您只需要一个对象即可管理组件中的所有订阅。