Chore: some minor type fixes (#68402)

* some minor type fixes

* undo card change
This commit is contained in:
Ashley Harrison
2023-05-15 09:15:26 +01:00
committed by GitHub
parent 58aa098ed7
commit 07c725800b
11 changed files with 22 additions and 77 deletions

View File

@@ -879,9 +879,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"packages/grafana-ui/src/components/Cascader/Cascader.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx:5381": [ "packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@@ -902,14 +899,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.story.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx:5381": [ "packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"]
], ],
"packages/grafana-ui/src/components/DataSourceSettings/types.ts:5381": [ "packages/grafana-ui/src/components/DataSourceSettings/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -973,10 +964,7 @@ exports[`better eslint`] = {
], ],
"packages/grafana-ui/src/components/Graph/Graph.tsx:5381": [ "packages/grafana-ui/src/components/Graph/Graph.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx:5381": [ "packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -1071,10 +1059,6 @@ exports[`better eslint`] = {
"packages/grafana-ui/src/components/PanelChrome/index.ts:5381": [ "packages/grafana-ui/src/components/PanelChrome/index.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-ui/src/components/QueryField/QueryField.tsx:5381": [ "packages/grafana-ui/src/components/QueryField/QueryField.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"]
@@ -6020,11 +6004,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/types/unified-alerting.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/test/core/redux/mocks.ts:5381": [ "public/test/core/redux/mocks.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@@ -6066,14 +6045,6 @@ exports[`better eslint`] = {
"public/test/jest-setup.ts:5381": [ "public/test/jest-setup.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/test/jest-shim.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/test/lib/common.ts:5381": [ "public/test/lib/common.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@@ -6083,16 +6054,13 @@ exports[`better eslint`] = {
"public/test/matchers/toEmitValuesWith.ts:5381": [ "public/test/matchers/toEmitValuesWith.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/test/matchers/utils.ts:5381": [ "public/test/matchers/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/test/mocks/workers.ts:5381": [ "public/test/mocks/workers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/test/specs/helpers.ts:5381": [ "public/test/specs/helpers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],

View File

@@ -18,7 +18,7 @@ module.exports = {
roots: ['<rootDir>/public/app', '<rootDir>/public/test', '<rootDir>/packages'], roots: ['<rootDir>/public/app', '<rootDir>/public/test', '<rootDir>/packages'],
testRegex: '(\\.|/)(test)\\.(jsx?|tsx?)$', testRegex: '(\\.|/)(test)\\.(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
setupFiles: ['jest-canvas-mock', './public/test/jest-shim.ts', './public/test/jest-setup.ts'], setupFiles: ['jest-canvas-mock', './public/test/jest-setup.ts'],
testTimeout: 30000, testTimeout: 30000,
resolver: `<rootDir>/public/test/jest-resolver.js`, resolver: `<rootDir>/public/test/jest-resolver.js`,
setupFilesAfterEnv: ['./public/test/setupTests.ts'], setupFilesAfterEnv: ['./public/test/setupTests.ts'],

View File

@@ -49,7 +49,7 @@ export interface CascaderOption {
/** /**
* The value used under the hood * The value used under the hood
*/ */
value: any; value: string;
/** /**
* The label to display in the UI * The label to display in the UI
*/ */

View File

@@ -3,12 +3,11 @@ import { useArgs } from '@storybook/client-api';
import { Meta, StoryFn } from '@storybook/react'; import { Meta, StoryFn } from '@storybook/react';
import React from 'react'; import React from 'react';
import { DataSourceSettings } from '@grafana/data';
import { DataSourceHttpSettings } from './DataSourceHttpSettings'; import { DataSourceHttpSettings } from './DataSourceHttpSettings';
import mdx from './DataSourceHttpSettings.mdx'; import mdx from './DataSourceHttpSettings.mdx';
import { HttpSettingsProps } from './types';
const settingsMock: DataSourceSettings<any, any> = { const settingsMock: HttpSettingsProps['dataSourceConfig'] = {
id: 4, id: 4,
orgId: 1, orgId: 1,
uid: 'x', uid: 'x',

View File

@@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css'; import { css, cx } from '@emotion/css';
import React, { useState, useCallback } from 'react'; import React, { useState, useCallback } from 'react';
import { DataSourceSettings, SelectableValue } from '@grafana/data'; import { SelectableValue } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors'; import { selectors } from '@grafana/e2e-selectors';
import { useTheme2 } from '../../themes'; import { useTheme2 } from '../../themes';
@@ -82,7 +82,7 @@ export const DataSourceHttpSettings = (props: HttpSettingsProps) => {
let urlTooltip; let urlTooltip;
const onSettingsChange = useCallback( const onSettingsChange = useCallback(
(change: Partial<DataSourceSettings<any, any>>) => { (change: Partial<typeof dataSourceConfig>) => {
onChange({ onChange({
...dataSourceConfig, ...dataSourceConfig,
...change, ...change,

View File

@@ -135,7 +135,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
renderTooltip = () => { renderTooltip = () => {
const { children, series, timeZone } = this.props; const { children, series, timeZone } = this.props;
const { pos, activeItem, isTooltipVisible } = this.state; const { pos, activeItem, isTooltipVisible } = this.state;
let tooltipElement: React.ReactElement<VizTooltipProps> | null = null; let tooltipElement: React.ReactElement<VizTooltipProps> | undefined;
if (!isTooltipVisible || !pos || series.length === 0) { if (!isTooltipVisible || !pos || series.length === 0) {
return null; return null;
@@ -147,18 +147,17 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
if (tooltipElement) { if (tooltipElement) {
return; return;
} }
// @ts-ignore
const childType = c && c.type && (c.type.displayName || c.type.name); const childType = c && c.type && (c.type.displayName || c.type.name);
if (childType === VizTooltip.displayName) { if (childType === VizTooltip.displayName) {
tooltipElement = c as React.ReactElement<VizTooltipProps>; tooltipElement = c;
} }
}); });
// If no tooltip provided, skip rendering // If no tooltip provided, skip rendering
if (!tooltipElement) { if (!tooltipElement) {
return null; return null;
} }
const tooltipElementProps = (tooltipElement as React.ReactElement<VizTooltipProps>).props; const tooltipElementProps = tooltipElement.props;
const tooltipMode = tooltipElementProps.mode || 'single'; const tooltipMode = tooltipElementProps.mode || 'single';
@@ -203,7 +202,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
const tooltipContent = React.createElement(tooltipContentRenderer, { ...tooltipContentProps }); const tooltipContent = React.createElement(tooltipContentRenderer, { ...tooltipContentProps });
return React.cloneElement<VizTooltipProps>(tooltipElement as React.ReactElement<VizTooltipProps>, { return React.cloneElement(tooltipElement, {
content: tooltipContent, content: tooltipContent,
position: { x: pos.pageX, y: pos.pageY }, position: { x: pos.pageX, y: pos.pageY },
offset: { x: 10, y: 10 }, offset: { x: 10, y: 10 },

View File

@@ -14,16 +14,10 @@ export interface PluginSignatureBadgeProps extends HTMLAttributes<HTMLDivElement
/** /**
* @public * @public
*/ */
export const PluginSignatureBadge = ({ status, ...otherProps }: PluginSignatureBadgeProps) => { export const PluginSignatureBadge = ({ status, color, ...otherProps }: PluginSignatureBadgeProps) => {
const display = getSignatureDisplayModel(status); const display = getSignatureDisplayModel(status);
return ( return (
<Badge <Badge text={display.text} color={display.color} icon={display.icon} tooltip={display.tooltip} {...otherProps} />
text={display.text}
color={display.color as any}
icon={display.icon}
tooltip={display.tooltip}
{...otherProps}
/>
); );
}; };

View File

@@ -23,7 +23,7 @@ export type Alert = {
}; };
export function hasAlertState(alert: Alert, state: PromAlertingRuleState | GrafanaAlertState): boolean { export function hasAlertState(alert: Alert, state: PromAlertingRuleState | GrafanaAlertState): boolean {
return mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) === state; return mapStateWithReasonToBaseState(alert.state) === state;
} }
interface RuleBase { interface RuleBase {
@@ -185,7 +185,7 @@ export interface SilenceFilterState {
interface EvalMatch { interface EvalMatch {
metric: string; metric: string;
tags?: any; tags?: Record<string, string>;
value: number; value: number;
} }
@@ -208,7 +208,7 @@ export interface StateHistoryItem {
time: number; time: number;
timeEnd: number; timeEnd: number;
text: string; text: string;
tags: any[]; tags: string[];
login: string; login: string;
email: string; email: string;
avatarUrl: string; avatarUrl: string;

View File

@@ -1,15 +0,0 @@
(global as any).requestAnimationFrame = (callback: any) => {
setTimeout(callback, 0);
};
(Promise.prototype as any).finally = function (onFinally: any) {
return this.then(
/* onFulfilled */
(res: any) => Promise.resolve(onFinally()).then(() => res),
/* onRejected */
(err: any) =>
Promise.resolve(onFinally()).then(() => {
throw err;
})
);
};

View File

@@ -3,7 +3,7 @@ import { Observable, Subscription } from 'rxjs';
import { expectObservable, forceObservableCompletion } from './utils'; import { expectObservable, forceObservableCompletion } from './utils';
function tryExpectations(received: any[], expectations: (received: any[]) => void): jest.CustomMatcherResult { function tryExpectations(received: unknown[], expectations: (received: unknown[]) => void): jest.CustomMatcherResult {
try { try {
expectations(received); expectations(received);
return { return {

View File

@@ -5,12 +5,12 @@ class LayoutMockWorker {
constructor() {} constructor() {}
postMessage(data: any) { postMessage(data: any) {
const { nodes, edges, config } = data; const { nodes, edges, config } = data;
this.timeout = setTimeout(() => { this.timeout = window.setTimeout(() => {
this.timeout = undefined; this.timeout = undefined;
layout(nodes, edges, config); layout(nodes, edges, config);
// @ts-ignore // @ts-ignore
this.onmessage({ data: { nodes, edges } }); this.onmessage({ data: { nodes, edges } });
}, 1) as any; }, 1);
} }
terminate() { terminate() {
if (this.timeout) { if (this.timeout) {