Skip to content

bug(mat-tree): mat-tree reports a compilation error wher used with a trackBy option in NestedTreeControl #21364

Closed
@POFerro

Description

@POFerro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/tree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions