Skip to content

Commit 6a79968

Browse files
committed
chore: remove explicit any from event handlers and normalize React type imports
1 parent 0931894 commit 6a79968

42 files changed

Lines changed: 107 additions & 99 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/component/1d-2d/FieldEdition.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { PopoverProps } from '@blueprintjs/core';
22
import { Popover } from '@blueprintjs/core';
33
import styled from '@emotion/styled';
44
import { yupResolver } from '@hookform/resolvers/yup';
5-
import type { MouseEvent, ReactNode } from 'react';
5+
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
66
import { useState } from 'react';
77
import { useForm } from 'react-hook-form';
88
import * as Yup from 'yup';
@@ -75,7 +75,7 @@ function Field(props: FieldProps) {
7575
resolver: yupResolver(validationSchema(inputType)),
7676
});
7777

78-
function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
78+
function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
7979
if (event.key === 'Enter') {
8080
void handleSubmit(onChange)();
8181
}

src/component/1d/FloatPublicationString.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from '@emotion/styled';
22
import type { BoundingBox, Spectrum, TextStyle } from '@zakodium/nmrium-core';
3+
import type { SVGProps } from 'react';
34
import { useCallback, useEffect, useMemo, useState } from 'react';
45
import { BsArrowsMove } from 'react-icons/bs';
56
import { FaEdit, FaTimes } from 'react-icons/fa';
@@ -19,7 +20,7 @@ import { useACSSettings } from '../hooks/use_acs_settings.js';
1920
import { usePublicationStrings } from '../hooks/use_publication_strings.js';
2021
import { PublicationStringModal } from '../modal/PublicationStringModal.js';
2122

22-
const MARKERS: Record<string, React.SVGProps<SVGTSpanElement>> = {
23+
const MARKERS: Record<string, SVGProps<SVGTSpanElement>> = {
2324
'++': { baselineShift: 'super' },
2425
'--': { baselineShift: 'sub' },
2526
'**': { fontStyle: 'italic' },

src/component/1d/peaks/PeakEditionManager.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ interface PeakEditionListenerProps {
4040
}
4141

4242
interface PeaksEditionContextProps {
43-
onEdit: (
44-
e: React.MouseEvent,
45-
peak?: Required<PeakEditionListenerProps>,
46-
) => void;
43+
onEdit: (e: MouseEvent, peak?: Required<PeakEditionListenerProps>) => void;
4744
id?: string;
4845
}
4946

src/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Spectrum1D, Spectrum2D } from '@zakodium/nmrium-core';
22
import { Filters1D } from 'nmr-processing';
3-
import type { ReactNode } from 'react';
3+
import type { ReactNode, SVGAttributes } from 'react';
44

55
import { getSlice } from '../../../../data/data2d/Spectrum2D/index.js';
66
import { useChartData } from '../../../context/ChartContext.js';
@@ -18,7 +18,7 @@ import {
1818

1919
import { useActivePhaseTraces } from './useActivePhaseTraces.js';
2020

21-
interface BaseComponentProps extends React.SVGAttributes<SVGGElement> {
21+
interface BaseComponentProps extends SVGAttributes<SVGGElement> {
2222
children?: ReactNode;
2323
}
2424

src/component/EventsTrackers/BrushTracker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const initialState: BrushTrackerState = {
8282
boundingRect: null,
8383
};
8484

85-
function stopPageScrolling(event: any) {
85+
function stopPageScrolling(event: globalThis.WheelEvent) {
8686
event.preventDefault();
8787
}
8888

src/component/SVGTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import type { SVGAttributes } from 'react';
12
import { createContext, useContext, useMemo } from 'react';
23

34
type CellTextProps = Omit<
4-
React.SVGAttributes<SVGTextElement>,
5+
SVGAttributes<SVGTextElement>,
56
'x' | 'y' | 'width' | 'height'
67
>;
78
type CellBoxProps = Omit<
8-
React.SVGAttributes<SVGRectElement>,
9+
SVGAttributes<SVGRectElement>,
910
'x' | 'y' | 'width' | 'height' | 'dx' | 'dy'
1011
>;
1112

src/component/elements/ActionsButtonsPopover.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { PopoverProps } from '@blueprintjs/core';
22
import { Popover } from '@blueprintjs/core';
33
import type { Interpolation, Theme } from '@emotion/react';
44
import styled from '@emotion/styled';
5-
import type { CSSProperties } from 'react';
5+
import type { CSSProperties, MouseEvent } from 'react';
66
import { useState } from 'react';
77
import type { ButtonProps } from 'react-science/ui';
88
import { Button } from 'react-science/ui';
@@ -173,7 +173,7 @@ export function ActionsButtonsPopover(props: ActionsButtonsPopoverProps) {
173173

174174
const { visibleButtons, disablePopover } = filterButtons(buttons);
175175

176-
function handleMouseEnter(event: any) {
176+
function handleMouseEnter(event: MouseEvent<HTMLElement>) {
177177
const { clientX, clientY, currentTarget } = event;
178178
if (!(currentTarget instanceof Element)) return;
179179
const rect = currentTarget.getBoundingClientRect();
@@ -193,13 +193,12 @@ export function ActionsButtonsPopover(props: ActionsButtonsPopoverProps) {
193193
popoverClassName="actions-buttons-popover"
194194
interactionKind="hover"
195195
enforceFocus={false}
196-
onOpening={handleMouseEnter}
197196
disabled={disablePopover || disabled}
198197
renderTarget={({ onMouseEnter, isOpen, ...otherProps }) => (
199198
<Wrapper
200199
{...targetProps}
201200
{...otherProps}
202-
onMouseEnter={(event: any) => {
201+
onMouseEnter={(event: MouseEvent<HTMLElement>) => {
203202
handleMouseEnter(event);
204203
onMouseEnter?.(event);
205204
}}

src/component/elements/Alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ButtonProps } from '@blueprintjs/core';
22
import { Button, DialogBody, DialogFooter } from '@blueprintjs/core';
33
import styled from '@emotion/styled';
4-
import type { ReactNode } from 'react';
4+
import type { MouseEvent, ReactNode } from 'react';
55
import { createContext, useContext, useMemo, useState } from 'react';
66

77
import { StandardDialog } from './StandardDialog.tsx';
@@ -108,7 +108,7 @@ interface AlertsProps {
108108
function Alerts(props: AlertsProps) {
109109
const { alerts, onHide } = props;
110110

111-
function optionsHandler(e: React.MouseEvent, options: any) {
111+
function optionsHandler(e: MouseEvent, options: any) {
112112
const { onClick = () => null, preventClose = false, id } = options;
113113
onClick(e);
114114
e.stopPropagation();

src/component/elements/ColumnWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
interface ColumnWrapperProps extends React.InputHTMLAttributes<HTMLDivElement> {
1+
import type { InputHTMLAttributes } from 'react';
2+
3+
interface ColumnWrapperProps extends InputHTMLAttributes<HTMLDivElement> {
24
stopPropagation?: boolean;
35
}
46

src/component/elements/DialogManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ interface WithDialogOptions {
126126
}
127127

128128
export function withDialog<P extends object>(
129-
WrappedComponent: React.ComponentType<P>,
129+
WrappedComponent: ComponentType<P>,
130130
options: WithDialogOptions = {},
131131
) {
132132
const { dialogName, force = false } = options;

0 commit comments

Comments
 (0)