繁体   English   中英

类型'any []'的参数不能分配给'(value:[any,Campaign []])=> void'类型的参数

[英]Argument of type 'any[]' is not assignable to parameter of type '(value: [any, Campaign[]]) => void'

嗨我收到我的代码中的打字稿错误。 以下是我的代码。

combineLatest(
          this.translateService.get('CLONE_FLIGHT', { item: this.flight.name}),
          this.flightsService.getCampaignsToClone(this.flight.id)
        ).subscribe([  header, campaigns]) => { 
          console.log('test');
        });

我收到的错误是

Argument of type 'any[]' is not assignable to parameter of type '(value: [any, Campaign[]]) => void'.
  Type 'any[]' provides no match for the signature '(value: [any, Campaign[]]): void'.ts(2345)
Cannot find name 'campaigns'.ts(2304)

translateService.get的方法签名如下

get(key: string | Array<string>, interpolateParams?: Object): Observable<string | any>;

方法调用flightsService.getCampaignsToClone(this.flight.id)

getCampaignsToClone(flightId: string){
    let campaigns: Campaign[] = [
      {  id:"1", name: "test campaign 001", createdOn:"",lastUpdated: "", createdBy: null,
      type:null, status: null, startDate: null, endDate: null, budget: null, description: "",
      account: null },
      {  id:"2", name: "test campaign 002", createdOn:"",lastUpdated: "", createdBy: null,
      type:null, status: null, startDate: null, endDate: null, budget: null, description: "",
      account: null },
      {  id:"3", name: "test campaign 003", createdOn:"",lastUpdated: "", createdBy: null,
      type:null, status: null, startDate: null, endDate: null, budget: null, description: "",
      account: null }
     ];
    return Observable.of(campaigns);

  }

我想要实现的代码是首先解析属性'CLONE_FLIGHT'并加载广告系列对象,然后在订阅中我想调用一个模态对话框。 但是我得到上面的错误我是打字稿和观察者的新手。

感谢任何帮助非常感谢prasanth

这是我应该写的语法问题

combineLatest(
  this.translateService.get('CLONE_FLIGHT', { item: this.flight.name}),
  this.flightsService.getCampaignsToClone(this.flight.id)
).subscribe( ([header, campaigns]) => { 
  console.log(header);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM