diff --git a/.changeset/few-eyes-provide.md b/.changeset/few-eyes-provide.md new file mode 100644 index 00000000..48c0a09f --- /dev/null +++ b/.changeset/few-eyes-provide.md @@ -0,0 +1,5 @@ +--- +"@studiocms/ui": patch +--- + +Fixes global window augmentation for tooltips (no user-facing changes, just better types!) diff --git a/.vscode/settings.json b/.vscode/settings.json index cc27ec5a..381af5c6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -45,5 +45,8 @@ "material-icon-theme.files.associations": { "*.e2e.ts": "playwright", "*.test.ts": "vitest" + }, + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome" } } diff --git a/packages/studiocms_ui/src/components/Tooltip/tooltip.ts b/packages/studiocms_ui/src/components/Tooltip/tooltip.ts index fa68a347..4443a9d8 100644 --- a/packages/studiocms_ui/src/components/Tooltip/tooltip.ts +++ b/packages/studiocms_ui/src/components/Tooltip/tooltip.ts @@ -327,7 +327,6 @@ function loadTooltips() { const anchor = tooltipInstance.getAnchor(); const popup = tooltipInstance.tooltip; - // @ts-expect-error window.sui.tooltips.instances.set(tooltipInstance.container.id, tooltipInstance); anchor.addEventListener('mouseenter', () => { @@ -394,11 +393,8 @@ function loadTooltips() { }); } -// TODO: Investigate why global type definitions are not being recognized -// @ts-expect-error window.sui = window.sui ?? {}; -// @ts-expect-error window.sui.tooltips = { instances: new Map(), diff --git a/packages/studiocms_ui/src/events.d.ts b/packages/studiocms_ui/src/events.d.ts index 31e3bf28..00935cb6 100644 --- a/packages/studiocms_ui/src/events.d.ts +++ b/packages/studiocms_ui/src/events.d.ts @@ -1,3 +1,5 @@ +/** biome-ignore-all lint/correctness/noUnusedVariables: Global augments */ + /** * CustomEventMap defines the custom events used in the application. * @@ -39,6 +41,18 @@ interface SuiTooltipApi { hide: (id: string) => void; } +interface Window { + /** + * The StudioCMS UI API, which includes various tools and utilities for the UI. + */ + sui: { + /** + * The tooltip API, which provides methods for managing tooltips in the UI. + */ + tooltips: SuiTooltipApi; + }; +} + /** * Extends the global `Document` interface to include custom event handling methods. * @@ -89,16 +103,4 @@ declare global { */ dispatchEvent(ev: CustomEventMap[K]): void; } - - interface Window { - /** - * The StudioCMS UI API, which includes various tools and utilities for the UI. - */ - sui: { - /** - * The tooltip API, which provides methods for managing tooltips in the UI. - */ - tooltips: SuiTooltipApi; - }; - } }