Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 13e3271

Browse files
Improve connectMenu type (#318)
* Improve connectMenu type Changed connectMenu type to specify that the function deals with React components, not just any * Export ConnectMenuProps
1 parent ab5b8f9 commit 13e3271

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/index.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare module "react-contextmenu" {
2222
collect?: {(data: any): any},
2323
disable?: boolean,
2424
holdToDisplay?: number,
25-
renderTag?: React.ReactType,
25+
renderTag?: React.ElementType,
2626
mouseButton?: number,
2727
disableIfShiftIsPressed?: boolean,
2828
}
@@ -47,11 +47,20 @@ declare module "react-contextmenu" {
4747
onClick?: {(event: React.TouchEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>, data: Object, target: HTMLElement): void} | Function,
4848
}
4949

50+
export interface ConnectMenuProps {
51+
id: string;
52+
trigger: any;
53+
}
54+
5055
export const ContextMenu: React.ComponentClass<ContextMenuProps>;
5156
export const ContextMenuTrigger: React.ComponentClass<ContextMenuTriggerProps>;
5257
export const MenuItem: React.ComponentClass<MenuItemProps>;
5358
export const SubMenu: React.ComponentClass<SubMenuProps>;
54-
export function connectMenu(menuId: string): (menu: any) => any;
59+
export function connectMenu<P>(
60+
menuId: string
61+
): (
62+
Child: React.ComponentType<P & ConnectMenuProps>
63+
) => React.ComponentType<P>;
5564
export function showMenu(opts?: any, target?: HTMLElement): void;
5665
export function hideMenu(opts?: any, target?: HTMLElement): void;
5766
}

0 commit comments

Comments
 (0)