chore(typescript): appease ts-go stricter type inference in callbacks

This commit is contained in:
Jack Westbrook
2025-12-01 12:28:44 +01:00
parent eb84c5d02f
commit 8a93d5331a
14 changed files with 30 additions and 30 deletions
@@ -1,6 +1,6 @@
import { css, cx } from '@emotion/css';
import { CSSProperties, useCallback, useMemo, useState } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FixedSizeList } from 'react-window';
import { GrafanaTheme2 } from '@grafana/data';
@@ -235,7 +235,7 @@ export function AlertInstanceModalSelector({
{!loading && (
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<FixedSizeList itemSize={50} height={height} width={width} itemCount={filteredRulesKeys.length}>
{RuleRow}
</FixedSizeList>
@@ -263,7 +263,7 @@ export function AlertInstanceModalSelector({
{selectedRule && rulesWithInstances[selectedRule].length && !loading && (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<FixedSizeList
itemSize={32}
height={height}
@@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css';
import { useState } from 'react';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -124,7 +124,7 @@ export function PayloadEditor({
<div className={styles.editorWrapper}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<CodeEditor
containerStyles={styles.editorContainer}
width={width}
@@ -4,7 +4,7 @@ import { Location } from 'history';
import { useRef, useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { useToggle } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -306,7 +306,7 @@ export const TemplateForm = ({ originalTemplate, prefill, alertmanager }: Props)
</div>
<Box flex={1}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<TemplateEditor
value={getValues('content')}
onBlur={(value) => setValue('content', value)}
@@ -1,6 +1,6 @@
import { css, cx } from '@emotion/css';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { t } from '@grafana/i18n';
@@ -44,7 +44,7 @@ export function TemplateContentAndPreview({
<Box flex={1}>
<div className={styles.viewerContainer({ height: 400 })}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<TemplateEditor
value={templateContent}
containerStyles={styles.editorContainer}
@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
import { noop } from 'lodash';
import { CSSProperties, useCallback, useMemo, useState } from 'react';
import { useAsync, useDebounce } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FixedSizeList } from 'react-window';
import { GrafanaTheme2 } from '@grafana/data';
@@ -257,7 +257,7 @@ export const DashboardPicker = ({ dashboardUid, panelId, isOpen, onChange, onDis
{!isDashSearchFetching && (
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<FixedSizeList
ref={scrollToItem}
itemSize={50}
@@ -291,7 +291,7 @@ export const DashboardPicker = ({ dashboardUid, panelId, isOpen, onChange, onDis
{selectedDashboardUid && !isDashboardFetching && (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<FixedSizeList itemSize={32} height={height} width={width} itemCount={filteredPanels.length}>
{PanelRow}
</FixedSizeList>
@@ -1,6 +1,6 @@
import { css } from '@emotion/css';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FieldConfigSource, FieldMatcherID, GrafanaTheme2, LoadingState } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -67,7 +67,7 @@ export function PreviewRuleResult(props: Props): React.ReactElement | null {
)}
<div className={styles.table}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<div style={{ width: `${width}px`, height: `${height}px` }}>
<PanelRenderer
title=""
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { memo, useEffect, useMemo } from 'react';
import { useLocation, useParams } from 'react-router-dom-v5-compat';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans } from '@grafana/i18n';
@@ -197,7 +197,7 @@ const BrowseDashboardsPage = memo(({ queryParams }: { queryParams: Record<string
<div className={styles.subView}>
<AutoSizer>
{({ width, height }) =>
{({ width, height }: Size) =>
isSearching ? (
<SearchView
permissions={permissions}
@@ -1,6 +1,6 @@
import { css } from '@emotion/css';
import { memo, useEffect } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { t } from '@grafana/i18n';
@@ -73,7 +73,7 @@ const RecentlyDeletedPage = memo(() => {
<div className={styles.subView}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<SearchView
permissions={permissions}
width={width}
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { PureComponent } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { Subscription } from 'rxjs';
import { FieldConfigSource, GrafanaTheme2, NavModel, NavModelItem, PageLayoutType } from '@grafana/data';
@@ -201,7 +201,7 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
{this.renderPanelToolbar(styles)}
<div className={styles.panelWrapper}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width < 3 || height < 3) {
return null;
}
@@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import { useCallback, useEffect, useState } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { useParams } from 'react-router-dom-v5-compat';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -119,7 +119,7 @@ export const SoloPanel = ({ dashboard, notFound, panel, panelId, timezone }: Sol
return (
<div className={styles.container}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width === 0) {
return null;
}
@@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css';
import { useMemo, useRef, useEffect, useState, lazy, Suspense, useCallback } from 'react';
import { useMeasure } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { SelectableValue, GrafanaTheme2 } from '@grafana/data';
import { t, Trans } from '@grafana/i18n';
@@ -349,7 +349,7 @@ LIMIT
const renderStandaloneEditor = () => (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<SQLEditor
query={query.expression || initialQuery}
onChange={onEditorChange}
@@ -1,6 +1,6 @@
import { cloneDeep } from 'lodash';
import { PureComponent } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import {
applyFieldOverrides,
@@ -292,7 +292,7 @@ export class InspectDataTab extends PureComponent<Props, State> {
</div>
<div className={styles.content}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width === 0) {
return null;
}
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { useMemo } from 'react';
import { useAsync } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { of } from 'rxjs';
import { GrafanaTheme2, PluginMeta, PluginType } from '@grafana/data';
@@ -52,7 +52,7 @@ export function PluginUsage({ plugin }: Props) {
</Trans>
</div>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
return (
<SearchResultsTable
response={found}
@@ -1,6 +1,6 @@
import { nanoid } from 'nanoid';
import { ReactElement, useState } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { sceneUtils, VizConfigBuilders } from '@grafana/scenes';
import {
@@ -56,7 +56,7 @@ function LogViewScene(): ReactElement | null {
actions={<LogViewFilters provider={data} filteredProvider={filteredData} filter={filter} onChange={setFilter} />}
>
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<VizGridLayout minHeight={height} minWidth={width}>
<VizPanel title="" viz={logsViz} dataProvider={filteredData} />
</VizGridLayout>