Chore: some minor type fixes (#68402)

* some minor type fixes

* undo card change
pull/68438/head
Ashley Harrison 2 years ago committed by GitHub
parent 58aa098ed7
commit 07c725800b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      .betterer.results
  2. 2
      jest.config.js
  3. 2
      packages/grafana-ui/src/components/Cascader/Cascader.tsx
  4. 5
      packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.story.tsx
  5. 4
      packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx
  6. 9
      packages/grafana-ui/src/components/Graph/Graph.tsx
  7. 10
      packages/grafana-ui/src/components/PluginSignatureBadge/PluginSignatureBadge.tsx
  8. 6
      public/app/types/unified-alerting.ts
  9. 15
      public/test/jest-shim.ts
  10. 2
      public/test/matchers/toEmitValuesWith.ts
  11. 4
      public/test/mocks/workers.ts

@ -879,9 +879,6 @@ exports[`better eslint`] = {
[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/Cascader/Cascader.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx:5381": [
[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.", "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": [
[0, 0, 0, "Unexpected any. Specify a different type.", "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"]
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
"packages/grafana-ui/src/components/DataSourceSettings/types.ts:5381": [
[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": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "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"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-ui/src/components/Graph/GraphContextMenu.tsx:5381": [
[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": [
[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": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[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.", "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": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -6066,14 +6045,6 @@ exports[`better eslint`] = {
"public/test/jest-setup.ts:5381": [
[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": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -6083,16 +6054,13 @@ exports[`better eslint`] = {
"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.", "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.", "2"]
],
"public/test/matchers/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"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.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/specs/helpers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],

@ -18,7 +18,7 @@ module.exports = {
roots: ['<rootDir>/public/app', '<rootDir>/public/test', '<rootDir>/packages'],
testRegex: '(\\.|/)(test)\\.(jsx?|tsx?)$',
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,
resolver: `<rootDir>/public/test/jest-resolver.js`,
setupFilesAfterEnv: ['./public/test/setupTests.ts'],

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

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

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

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

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

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

@ -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;
})
);
};

@ -3,7 +3,7 @@ import { Observable, Subscription } from 'rxjs';
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 {
expectations(received);
return {

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

Loading…
Cancel
Save