fix(Tree): DraggableFn params type (#36648)

* fix(Tree): DraggableFn params type

* chore: add blank line

* test: add typ test for draggable Fn

* test: add typ test for draggable Fn

Co-authored-by: tianyuan233 <zty.dev@outlook.com>
This commit is contained in:
Tianyuan Zhang 2022-07-22 20:26:52 +08:00 committed by GitHub
parent ad7df07680
commit 09de419253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -95,7 +95,8 @@ export interface AntTreeNodeDropEvent {
// [Legacy] Compatible for v3
export type TreeNodeNormal = DataNode;
type DraggableFn = (node: AntTreeNode) => boolean;
type DraggableFn = (node: DataNode) => boolean;
interface DraggableConfig {
icon?: React.ReactNode | false;
nodeDraggable?: DraggableFn;

View File

@ -1,6 +1,7 @@
import type { BasicDataNode } from 'rc-tree';
import * as React from 'react';
import { render } from '../../../tests/utils';
import type { DataNode } from '../index';
import Tree from '../index';
const { DirectoryTree } = Tree;
@ -74,4 +75,25 @@ describe('Tree.TypeScript', () => {
expect(container).toBeTruthy();
});
it('draggable params type', () => {
const { container } = render(
<Tree
treeData={[
{
title: 'Bamboo',
key: 'bamboo',
children: [
{
title: 'Little',
key: 'little',
},
],
},
]}
draggable={(node: DataNode) => node.title === 'Little'}
/>,
);
expect(container).toBeTruthy();
});
});