From 578c166f1d9814b4a6caf15e9db1e871b0c7b9b2 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Mon, 1 Jun 2026 15:43:18 +0200 Subject: [PATCH] fix: add explicit type annotations for callback params losing contextual typing When @ariakit/react updates its internal module structure (e.g. from @ariakit/react-core to @ariakit/react-components), contextual typing from external library component props can break, causing TS7006 'Parameter implicitly has an any type' errors in the Fresh Install Tests CI workflow. Add explicit type annotations to 5 callback parameters that depend on external library types for inference: - packages/ariakit/src/panel/Panel.tsx: setActiveId callback - packages/ariakit/src/toolbar/ToolbarButton.tsx: onMouseDown callback - packages/ariakit/src/panel/PanelFileInput.tsx: onChange callback - packages/ariakit/src/badge/Badge.tsx: onClick callback - packages/xl-ai/src/components/AIMenu/AIMenuController.tsx: outsidePress callback All annotations use React/DOM built-in types (MouseEvent, ChangeEvent) rather than library-specific types, making them resilient to future dependency updates. --- packages/ariakit/src/badge/Badge.tsx | 4 ++-- packages/ariakit/src/panel/Panel.tsx | 2 +- packages/ariakit/src/panel/PanelFileInput.tsx | 4 ++-- packages/ariakit/src/toolbar/ToolbarButton.tsx | 4 ++-- packages/xl-ai/src/components/AIMenu/AIMenuController.tsx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/ariakit/src/badge/Badge.tsx b/packages/ariakit/src/badge/Badge.tsx index 43b6cdd7d5..f81ca9ce5a 100644 --- a/packages/ariakit/src/badge/Badge.tsx +++ b/packages/ariakit/src/badge/Badge.tsx @@ -8,7 +8,7 @@ import { import { assertEmpty, mergeCSSClasses } from "@blocknote/core"; import { ComponentProps } from "@blocknote/react"; -import { forwardRef } from "react"; +import { type MouseEvent, forwardRef } from "react"; export const Badge = forwardRef< HTMLButtonElement, @@ -36,7 +36,7 @@ export const Badge = forwardRef< isSelected && "bn-ak-primary", )} aria-selected={isSelected === true} - onClick={(event) => onClick?.(event)} + onClick={(event: MouseEvent) => onClick?.(event)} onMouseEnter={onMouseEnter} ref={ref} > diff --git a/packages/ariakit/src/panel/Panel.tsx b/packages/ariakit/src/panel/Panel.tsx index 376f04a534..b988cbec01 100644 --- a/packages/ariakit/src/panel/Panel.tsx +++ b/packages/ariakit/src/panel/Panel.tsx @@ -32,7 +32,7 @@ export const Panel = forwardRef< { + setActiveId={(activeId: string | null | undefined) => { if (activeId) { setOpenTab(activeId); } diff --git a/packages/ariakit/src/panel/PanelFileInput.tsx b/packages/ariakit/src/panel/PanelFileInput.tsx index 4c6a876931..36917ff5a5 100644 --- a/packages/ariakit/src/panel/PanelFileInput.tsx +++ b/packages/ariakit/src/panel/PanelFileInput.tsx @@ -5,7 +5,7 @@ import { import { assertEmpty } from "@blocknote/core"; import { ComponentProps } from "@blocknote/react"; -import { forwardRef } from "react"; +import { forwardRef, type ChangeEvent } from "react"; export const PanelFileInput = forwardRef< HTMLInputElement, @@ -24,7 +24,7 @@ export const PanelFileInput = forwardRef< type={"file"} accept={accept} value={value ? value.name : undefined} - onChange={async (e) => onChange?.(e.target.files![0])} + onChange={async (e: ChangeEvent) => onChange?.(e.target.files![0])} placeholder={placeholder} /> diff --git a/packages/ariakit/src/toolbar/ToolbarButton.tsx b/packages/ariakit/src/toolbar/ToolbarButton.tsx index 0fddcb5905..cb2bf26cca 100644 --- a/packages/ariakit/src/toolbar/ToolbarButton.tsx +++ b/packages/ariakit/src/toolbar/ToolbarButton.tsx @@ -7,7 +7,7 @@ import { import { assertEmpty, isSafari, mergeCSSClasses } from "@blocknote/core"; import { ComponentProps } from "@blocknote/react"; -import { forwardRef } from "react"; +import { forwardRef, type MouseEvent } from "react"; type ToolbarButtonProps = ComponentProps["Generic"]["Toolbar"]["Button"]; @@ -46,7 +46,7 @@ export const ToolbarButton = forwardRef( )} // Needed as Safari doesn't focus button elements on mouse down // unlike other browsers. - onMouseDown={(e) => { + onMouseDown={(e: MouseEvent) => { if (isSafari()) { (e.currentTarget as HTMLButtonElement).focus(); } diff --git a/packages/xl-ai/src/components/AIMenu/AIMenuController.tsx b/packages/xl-ai/src/components/AIMenu/AIMenuController.tsx index 930c317fa6..be8f21f555 100644 --- a/packages/xl-ai/src/components/AIMenu/AIMenuController.tsx +++ b/packages/xl-ai/src/components/AIMenu/AIMenuController.tsx @@ -70,7 +70,7 @@ export const AIMenuController = (props: { // We should just be able to set `referencePress: true` instead of // using this listener, but this doesn't seem to trigger. // (probably because we don't assign the referenceProps to the reference element) - outsidePress: (event) => { + outsidePress: (event: MouseEvent) => { if (event.target instanceof Element) { const blockElement = event.target.closest(".bn-block"); if (