我想从Angular客户端访问Swagger REST API。 我已经使用Swagger Codegen生成了JS库以访问以下代码中的API-Company,CompanyService和CompanyList。
import { Component } from '@angular/core';
import { Company, CompanyService, CompanyList } from 'my-api';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@Component()
export class HomePage {
companies$: Observable<Company[]>;
constructor(private companyService: CompanyService) {}
ngOnInit() {
this.companies$ = this.companyService
.list()
.pipe(
map((a: CompanyList) => data)
);
}
}
上面的代码有效,并且我能够使用HTML页面中的companies$
管道访问async
,但是我的IDE-IntelliJ IDEA-在map
行中标记了以下内容错误
TS2345: Argument of type 'UnaryFunction<Observable<CompanyList>, Observable<Company[]>>' is not assignable to parameter of type 'UnaryFunction<Observable<CompanyList>, Observable<Company[]>>'.
Types of parameters 'source' and 'source' are incompatible.
Type 'Observable<CompanyList>' is not assignable to type 'Observable<CompanyList>'. Two different types with this name exist, but they are unrelated.
Property 'takeUntil' is missing in type 'Observable<CompanyList>'.
这是什么意思,以及如何解决?