Within the code snippet below, we have a definition for a type called Node
:
export type Node<T> = T extends ITreeNode ? T : never;
export interface ITreeNode extends TreeNodeBase<ITreeNode> {
enabled: boolean;
}
export abstract class Tree<Node> {
nodeEnableToggle(node: Node): void {
node.enabled = !node.enabled;
}
}
But why am I encountering this error message:
The property 'enabled' does not exist on type 'Node'
Even when T
is expected to extend from ITreeNode
?
I attempted another approach as well:
type Node<T> = T & ITreeNode;
initialize(source: Node): void {
this.dataSource.data = source.children;
}
Unfortunately, I faced the same issue:
The property 'children' does not exist on type 'Node'