palantir/blueprint

dataNode on TreeNode should not be optional

Open

#5.779 geöffnet am 30. Nov. 2022

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (2.167 Forks)batch import
Domain: APIP2Package: coreStatus: to triageType: breaking changeType: enhancementhelp wanted

Repository-Metriken

Stars
 (20.263 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 43T 10h) (27 gemergte PRs in 30 T)

Beschreibung

Environment

  • Package version(s):
  • Browser and OS versions:

Feature request

This line: https://github.com/palantir/blueprint/blob/develop/packages/core/src/components/tree/treeNode.tsx#L83

    /**
     * An optional custom user object to associate with the node.
     * This property can then be used in the `onClick`, `onContextMenu` and `onDoubleClick`
     * event handlers for doing custom logic per node.
     */
    nodeData?: T;

should not be optional. It prevents type checking. If a user wants that to be optional then they can pass in undefined as a union for the generic parameter

Examples

can't do:

const a: ITreeNode<{type: "a"}> = {} as ITreeNode<{type: "a"}>;

if (a.dataNode.type == "a") // can't do this as a.dataNode can be undefined

if user actually wants undefined they can do ITreeNode<{type: "a"} | undefined>

Contributor Guide