Skip to content

Commit

Permalink
Priyanshu kun/clean any (#1814)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Cleaned unnecessary `any` keyword.

## Description of the changes
- In this PR I cleaned unnecessary `any` keyword and I'm doing it
gradually.

## How was this change tested?
- I successfully ran linting and unit tests.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: priyanshu-kun <[email protected]>
  • Loading branch information
Priyanshu Sharma authored Sep 23, 2023
1 parent aa5b620 commit b5afeaa
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion packages/jaeger-ui/src/components/TraceDiff/TraceDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import * as React from 'react';
import { History as RouterHistory } from 'history';
import queryString from 'query-string';
import { connect } from 'react-redux';
import { match } from 'react-router-dom';
import { bindActionCreators, Dispatch } from 'redux';
Expand Down
7 changes: 4 additions & 3 deletions packages/jaeger-ui/src/components/common/RelativeDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import React from 'react';
import dayjs from 'dayjs';

import { formatRelativeDate } from '../../utils/date';

type Props = {
fullMonthName: boolean | undefined | null;
includeTime: boolean | undefined | null;
value: number | Date | any;
value: number | Date;
};

// TODO typescript doesn't understand text or null as react nodes
// https://github.com/Microsoft/TypeScript/issues/21699
export default function RelativeDate(props: Props): any {
export default function RelativeDate(props: Props): JSX.Element {
const { value, includeTime, fullMonthName } = props;
const m = dayjs.isDayjs(value) ? value : dayjs(value);
const dateStr = formatRelativeDate(m, Boolean(fullMonthName));
const timeStr = includeTime ? `, ${m.format('h:mm:ss a')}` : '';
return `${dateStr}${timeStr}`;
return <span>{`${dateStr}${timeStr}`}</span>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export default class DraggableManager {
tag: string | TNil;

// handlers for integration with DOM elements
handleMouseEnter: (event: React.MouseEvent<any>) => void;
handleMouseMove: (event: React.MouseEvent<any>) => void;
handleMouseLeave: (event: React.MouseEvent<any>) => void;
handleMouseDown: (event: React.MouseEvent<any>) => void;
handleMouseEnter: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseMove: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseLeave: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;
handleMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => void;

constructor({ getBounds, tag, resetBoundsOnResize = true, ...rest }: DraggableManagerOptions) {
this.handleMouseDown = this._handleDragEvent;
Expand Down Expand Up @@ -142,7 +142,7 @@ export default class DraggableManager {
this._bounds = undefined;
};

_handleMinorMouseEvent = (event: React.MouseEvent<any>) => {
_handleMinorMouseEvent = (event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => {
const { button, clientX, type: eventType } = event;
if (this._isDragging || button !== LEFT_MOUSE_BUTTON) {
return;
Expand Down Expand Up @@ -175,7 +175,7 @@ export default class DraggableManager {
});
};

_handleDragEvent = (event: MouseEvent | React.MouseEvent<any>) => {
_handleDragEvent = (event: MouseEvent | React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent>) => {
const { button, clientX, type: eventType } = event;
let type: EUpdateTypes | null = null;
let handler: ((update: DraggingUpdate) => void) | TNil;
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/DraggableManager/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type DraggableBounds = {
};

export type DraggingUpdate = {
event: React.MouseEvent<any> | MouseEvent;
event: React.MouseEvent<HTMLDivElement | SVGSVGElement, MouseEvent> | MouseEvent;
manager: DraggableManager;
tag: string | TNil;
type: EUpdateTypes;
Expand Down
6 changes: 1 addition & 5 deletions packages/jaeger-ui/src/utils/config/process-deprecation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ interface IDeprecation {
* - The value at the deprecated config property is moved to the new property
* - The value at the deprecated config property is ignored in favor of the value at the new property
*/
export default function processDeprecation(
config: Record<string, any>,
deprecation: IDeprecation,
issueWarning: boolean
) {
export default function processDeprecation(config: object, deprecation: IDeprecation, issueWarning: boolean) {
const { formerKey, currentKey } = deprecation;
if (_has(config, formerKey)) {
let isTransfered = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/readJsonFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function readJsonFile(fileList: { file: File }) {
}
try {
resolve(JSON.parse(reader.result));
/* eslint-disable @typescript-eslint/no-explicit-any */
} catch (error: any) {
reject(new Error(`Error parsing JSON: ${error.message}`));
}
Expand All @@ -38,7 +39,6 @@ export default function readJsonFile(fileList: { file: File }) {
try {
reader.readAsText(fileList.file);
} catch (error: any) {
// eslint-disable-next-line no-console
reject(new Error(`Error reading the JSON file: ${error.message}`));
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/utils/tracking/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
export const OPEN = 'open';
export const CLOSE = 'close';

export function getToggleValue(value: any) {
export function getToggleValue(value: boolean) {
return value ? CLOSE : OPEN;
}
4 changes: 3 additions & 1 deletion packages/jaeger-ui/src/utils/tracking/getTrackFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import _throttle from 'lodash/throttle';

import { trackEvent } from '.';

import { TNil } from '../../types';

// export for tests
export const ACTION_FILTER_SET = 'set';
export const ACTION_FILTER_CLEAR = 'clear';
Expand All @@ -33,5 +35,5 @@ const getTrackFilterClear = (category: string) =>
export default function getTrackFilter(category: string) {
const trackFilterSet = getTrackFilterSet(category);
const trackFilterClear = getTrackFilterClear(category);
return (value: any) => (value ? trackFilterSet() : trackFilterClear());
return (value: string | TNil) => (value ? trackFilterSet() : trackFilterClear());
}
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/utils/ts/pluckTruthy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/* eslint-disable @typescript-eslint/no-explicit-any */
// Because TypeScript doesn't believe in Array#filter(Boolean)
export default function pluckTruthy<T>(values: (T | any)[]): T[] {
const rv: T[] = [];
Expand Down

0 comments on commit b5afeaa

Please sign in to comment.