Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 0279c91

Browse files
committed
better TypeScript modifier types for usePopper
1 parent c359fb1 commit 0279c91

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

typings/react-popper.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ export class Popper<Modifiers> extends React.Component<
6565
{}
6666
> {}
6767

68-
export function usePopper(
68+
export function usePopper<Modifiers>(
6969
referenceElement?: Element | PopperJS.VirtualElement | null,
7070
popperElement?: HTMLElement | null,
71-
options?: Partial<PopperJS.Options> & {
71+
options?: Omit<Partial<PopperJS.Options>, 'modifiers'> & {
7272
createPopper?: typeof PopperJS.createPopper;
73+
modifiers?: ReadonlyArray<Modifier<Modifiers>>;
7374
}
7475
): {
7576
styles: { [key: string]: React.CSSProperties };

typings/tests/main-test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ const HookTest = () => {
6060
referenceElement,
6161
popperElement,
6262
{
63-
modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
63+
modifiers: [
64+
{
65+
name: 'arrow',
66+
options: { element: arrowElement as HTMLElement | undefined },
67+
},
68+
],
6469
}
6570
);
6671

0 commit comments

Comments
 (0)