Is there a way to typehint IDE for “let variable” type in Typescript and Angular?

as the

tableDataSource: MatTableDataSource<ToDoInterface>;

does not type the model,

this:

<ng-container matColumnDef="toDo">
  <th mat-header-cell *matHeaderCellDef mat-sort-header>ToDo</th>
  <td mat-cell *matCellDef="let model">
    <ng-container *ngIf="assertItemType(model) as toDoModel">
      {{toDoModel.toDo}}
    </ng-container>
  </td>
</ng-container>

where:

assertItemType(item: ToDoInterface): ToDoInterface {
  return item;
}

works.

but not sure if it the best way to do it

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)