1

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;
}
Raj
  • 11
  • 2

1 Answers1

0

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?

Boudi
  • 122
  • 1
  • 7
  • This is the production code with angular fire V4. with the upgrade to V5 the code broke. Can you suggest code that can fix this? – Raj Aug 13 '18 at 06:48
  • Delete the square brackets in line 1. It'll become like this: openInventorys: AngularFireList; – Boudi Aug 13 '18 at 09:16