ant-design/components/tree-select/interface.tsx
Kasra Bigdeli 4e116962f2 Updating type: TreeSelectProps.getPopupContainer (#14443)
TreeSelectProps extends AbstractSelectProps. However, the method signatures are different causing compilation issue with typescript:


```
Failed to compile.

/home/kasra/Desktop/Repos/frontend/node_modules/antd/lib/tree-select/interface.d.ts
Type error: Interface 'TreeSelectProps' incorrectly extends interface 'AbstractSelectProps'.
  Types of property 'getPopupContainer' are incompatible.
    Type '((triggerNode: Element) => HTMLElement) | undefined' is not assignable to type '((triggerNode?: Element | undefined) => HTMLElement) | undefined'.
      Type '(triggerNode: Element) => HTMLElement' is not assignable to type '(triggerNode?: Element | undefined) => HTMLElement'.
        Types of parameters 'triggerNode' and 'triggerNode' are incompatible.
          Type 'Element | undefined' is not assignable to type 'Element'.
            Type 'undefined' is not assignable to type 'Element'.  TS2430

    24 |     rootPId?: string;
    25 | }
  > 26 | export interface TreeSelectProps extends AbstractSelectProps {
       |                  ^
    27 |     autoFocus?: boolean;
    28 |     defaultValue?: string | number | Array<any>;
```
2019-01-21 17:14:02 +08:00

65 lines
2.1 KiB
TypeScript

import * as React from 'react';
import { AbstractSelectProps } from '../select';
export type TreeNode = TreeNodeNormal | TreeNodeSimpleMode;
export interface TreeNodeNormal {
value: string | number;
/**
* @deprecated Please use `title` instead.
*/
label?: React.ReactNode;
title?: React.ReactNode;
key: string;
isLeaf?: boolean;
disabled?: boolean;
disableCheckbox?: boolean;
selectable?: boolean;
children?: TreeNodeNormal[];
}
export interface TreeNodeSimpleMode {
/* It is possible to change `id` and `pId` prop keys using TreeDataSimpleMode so those keys can be anything */
[key: string]: string | boolean | React.ReactNode;
}
export interface TreeDataSimpleMode {
id?: string;
pId?: string;
rootPId?: string;
}
export interface TreeSelectProps extends AbstractSelectProps {
autoFocus?: boolean;
defaultValue?: string | number | Array<any>;
dropdownStyle?: React.CSSProperties;
filterTreeNode?: (inputValue: string, treeNode: any) => boolean | boolean;
getPopupContainer?: (triggerNode?: Element) => HTMLElement;
labelInValue?: boolean;
loadData?: (node: any) => void;
maxTagCount?: number;
maxTagPlaceholder?: React.ReactNode | ((omittedValues: any[]) => React.ReactNode);
multiple?: boolean;
notFoundContent?: React.ReactNode;
onChange?: (value: any, label: any, extra: any) => void;
onSearch?: (value: any) => void;
onSelect?: (value: any) => void;
onTreeExpand?: (keys: Array<string>) => void;
onFocus?: React.FocusEventHandler<HTMLInputElement>;
onBlur?: React.FocusEventHandler<HTMLInputElement>;
searchPlaceholder?: string;
searchValue?: string;
showCheckedStrategy?: 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
suffixIcon?: React.ReactNode;
treeCheckable?: boolean | React.ReactNode;
treeCheckStrictly?: boolean;
treeData?: Array<TreeNode>;
treeDataSimpleMode?: boolean | TreeDataSimpleMode;
treeDefaultExpandAll?: boolean;
treeDefaultExpandedKeys?: Array<string>;
treeExpandedKeys?: Array<string>;
treeNodeFilterProp?: string;
treeNodeLabelProp?: string;
value?: string | number | Array<any>;
}