New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(mat-tree): mat-tree reports a compilation error wher used with a trackBy option in NestedTreeControl #21364
Comments
An identical issue was reported with the framework a few days ago (angular/angular#40125), could it be the same as this one? Can you try the solution from the last comment to see if it resolves it? |
Hi @crisbeto , No, this case is different, I'll explain: While this change happened in the TreeControl classes the class MatTree didn't change to reflect the second generic parameter so now if K != T in TreeControl class the property type in MatTree will mismatch since it is defining the property type as being |
) (angular#21421) * fix(cdk/tree): add missing generic types to trackBy Fixes (angular#21364) * fix(cdk/tree): add missing generic types to trackBy Fixes (angular#21364)
This should be closed by #21421. |
Thanks for the heads-up. Closing as something that should be resolved. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi,
I have a mat-tree associated with the tree control:
public readonly mainMenuTreeControl = new NestedTreeControl<IMainMenuNode, string>(node => node.children, { trackBy: this.mainMenuItemTrackBy });
where
this.mainMenuItemTrackBy
is defined as(menuNode: IMainMenuNode): string{ ... }
when used in a view like
<mat-tree [dataSource]="..." [treeControl]="mainMenuTreeControl">...</mat-tree>
compiler reports an error:
error TS2322: Type 'NestedTreeControl<IMainMenuNode, string>' is not assignable to type 'TreeControl<IMainMenuNode, IMainMenuNode>'.
31 [treeControl]="mainMenuTreeControl"
from what I have seen in code I believe MatTree should in fact be MatTree<T, K =T> as is NestedTreeControl defined and the property treeControl should also be:
@Input() treeControl: TreeControl<T, K>;
Can you help me?
Thanks in advance
POFerro
The text was updated successfully, but these errors were encountered: