Typescript error after migrating to angular fire V5

36 views Asked by At

Error msg "Argument of type '{ 'itemType': string; 'qty': string; 'time': string; }' is not assignable to parameter of type 'openInventory[]'. Property 'length' is missing in type '{ 'itemType': string; 'qty': string; 'time': string; }'."

Snippet

  openInventorys: AngularFireList<openInventory[]>;
  openInventory: AngularFireObject<any>;

 addOpenInventory(org: any, type:string, qty:string) {
    this.openInventorys = this.af.list('/inventory/' + org+ '/openInventory') ;
    var openInventoryData = { 'itemType': type, 'qty': qty, 'time': moment().format('YYYY-MM-DD HH:mm') };
    this.openInventorys.push(openInventoryData);
  }

interface openInventory {
  $key?: string;
  itemType?: string;
  qty?: string;
  time?: string;
}
1

There are 1 answers

2
Boudi On

In line 1 there is a declaration of a list of openInventory (openInventory[]), while in line 6, there is a push of a single openInventory item.

Another thing, in line 4, there is a re-affectation of openInventorys at each method call. Is this the desired behavior?