You can find a minimum reproduction of the error at this stackblitz.
<mat-toolbar>
<a [matMenuTriggerFor]="index" mat-button *ngFor="let item of menuItems; let index = index">{{item.label}}</a>
<mat-menu #index="matMenu">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
</mat-toolbar>
In the code above, in version of Angular greater than 12, there appears to be a regression in how MatMenu works.
It results in an error of Type number is not assignable to type MatMenuPanel | null
This one bug not only blocks me from finishing my task but basically breaks my approach entirely.
Using the suggested work-around online of adding "exactOptionalPropertyTypes": false, to tsconfig.ts has had no effect.