tree-select icon indicating copy to clipboard operation
tree-select copied to clipboard

TreeNode Generic

Open SamKirkland opened this issue 5 years ago • 0 comments

Currently TreeNode does not accept a generic for its value prop. So the value is always type string | number.

However TreeSelect accepts a generic and defaults the type to DefaultValueType (RawValueType or RawValueType[])

I'd expect the following generic to work

type MyCustomValueType = "yes" | "no";

class App extends React.Component {
  render() {
    return (
      <TreeSelect<MyCustomValueType>>
        <TreeNode<MyCustomValueType> value="yes" title="yes" />
        <TreeNode<MyCustomValueType> value="no" title="no" />
        <TreeNode<MyCustomValueType> value="ts error" title="no" /> {/* Throws TS error */}
      </TreeSelect>
    );
  }
}

SamKirkland avatar Jun 02 '20 21:06 SamKirkland