CdkDragDrop type ambiguity in Angular Firebase tutorial

23 views Asked by At

im following this (https://developers.google.com/codelabs/building-a-web-app-with-angular-and-firebase#9) tutorial and when I run my angular app I get the following error

Argument of type 'CdkDragDrop<Task[] | null, any, any>' is not assignable to parameter of type 'CdkDragDrop<Task[], Task[], any>'.
  The types of 'container.data' are incompatible between these types.
    Type 'Task[] | null' is not assignable to type 'Task[]'.
      Type 'null' is not assignable to type 'Task[]'. [plugin angular-compiler]

and im not sure how to fix it, mostly because i dont understand why its mad at me, any insight would be appreciated,

This is the HTML

   
<mat-card cdkDropList id="inProgress" #inProgressList="cdkDropList" [cdkDropListData]="inProgress| async"
          [cdkDropListConnectedTo]="[todoList, doneList]" (cdkDropListDropped)="drop($event)" class="list">
          <p class="empty-label" *ngIf="(inProgress| async)?.length === 0">Empty list</p>
          <app-task (edit)="editTask('inProgress', $event)" *ngFor="let task of inProgress| async" cdkDrag
            [task]="task"></app-task>
        </mat-card>

and this is the method its calling


    drop(event: CdkDragDrop<Task[]>): void {
        if (event.previousContainer === event.container) {
          return;
        }
        const item = event.previousContainer.data[event.previousIndex];
        this.store.firestore.runTransaction(() => {
          const promise = Promise.all([
            this.store.collection(event.previousContainer.id).doc(item.id).delete(),
            this.store.collection(event.container.id).add(item),
          ]);
          return promise;
        });
        transferArrayItem(
          event.previousContainer.data,
          event.container.data,
          event.previousIndex,
          event.currentIndex
        );
      }

Ive tried adding a ? operator to the event pass because I thought it was passing a null value but that didnt seem to work. Beyond that im compeletely confused as to what this error even means

0

There are 0 answers