Here is what I currently have:
export interface RegionNode {
nodeSelected: boolean;
nodeEditable: boolean;
zone: Partial<Zone>;
parent: RegionNode | null;
children: RegionNode[];
}
Now, I am looking for a sleek solution to create a generic function that accomplishes this:
function setNodeAndChildrenProperty(node: RegionNode, property: keyof RegionNode, state: boolean): void {
// @ts-ignore
node[property] = state;
for (const child of node.children) {
setNodeAndChildrenProperty(child, property, state);
};
}
One issue I faced was having to resort to using @ts-ignore because I am unsure how to limit the list of permitted properties to only "nodeSelected" and "nodeEditable", as well as encountering other challenges.
What would be an elegant solution to address this dilemma?