diff --git a/src/misc/debounce.ts b/src/misc/debounce.ts index 72db5ba..858d12d 100644 --- a/src/misc/debounce.ts +++ b/src/misc/debounce.ts @@ -9,7 +9,7 @@ export interface DebouncedFunction any> * Simplest implementation of "debounce" function. * Returns function wrapper that delays original function call * until timeout since last call will be reached. - * Analogue of debounce from lodash/underscore. + * Similar to `debounce` from lodash/underscore. * * @param func Function. * @param timeout Timeout in milliseconds. diff --git a/src/react/error-boundary.tsx b/src/react/error-boundary.tsx index 05c7ff6..800142c 100644 --- a/src/react/error-boundary.tsx +++ b/src/react/error-boundary.tsx @@ -1,4 +1,4 @@ -import { Component, type ErrorInfo, type JSX, type ReactNode } from 'react'; +import { Component, type ErrorInfo, type ReactNode } from 'react'; export interface ErrorBoundaryProps { children?: ReactNode; @@ -34,7 +34,7 @@ export class ErrorBoundary extends Component{this.state.hasError ? fallback : children}; diff --git a/src/react/lifecycle.tsx b/src/react/lifecycle.tsx index 15fcf1e..af00680 100644 --- a/src/react/lifecycle.tsx +++ b/src/react/lifecycle.tsx @@ -1,4 +1,4 @@ -import { type JSX, type ReactNode, useEffect } from 'react'; +import { type ReactNode, useEffect } from 'react'; import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.ts'; import { useLatestRef } from './use-latest-ref.ts'; @@ -25,7 +25,7 @@ export interface LifecycleProps { * @param props Props. * @returns JSX Element. */ -export function Lifecycle(props: LifecycleProps): JSX.Element { +export function Lifecycle(props: LifecycleProps): ReactNode { const { children } = props; // because it is "event callbacks", we should call actual functions (from last render), diff --git a/src/react/merge-refs.ts b/src/react/merge-refs.ts index 2080d5b..addd953 100644 --- a/src/react/merge-refs.ts +++ b/src/react/merge-refs.ts @@ -1,4 +1,4 @@ -import type { Ref, RefObject, RefCallback, MutableRefObject } from 'react'; +import type { Ref, RefObject, RefCallback } from 'react'; /** * Create ref that updates all accepted refs from list. @@ -7,7 +7,7 @@ import type { Ref, RefObject, RefCallback, MutableRefObject } from 'react'; * @returns Merged ref. */ export function mergeRefs( - list: Array | RefObject | RefCallback | MutableRefObject | null | undefined>, + list: Array | RefObject | RefCallback | null | undefined>, ): Ref { return (value: T) => { for (const ref of list) { diff --git a/src/react/portal.tsx b/src/react/portal.tsx index eb6608d..bc72fc8 100644 --- a/src/react/portal.tsx +++ b/src/react/portal.tsx @@ -1,4 +1,4 @@ -import { type JSX, type ReactNode, useState } from 'react'; +import { type ReactNode, useState } from 'react'; import { createPortal } from 'react-dom'; import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.ts'; import { useLatestRef } from './use-latest-ref.ts'; @@ -60,7 +60,7 @@ const DEFAULTS = { * @param props Props. * @returns JSX.Element or null. */ -export function Portal(props: PortalProps): JSX.Element | null { +export function Portal(props: PortalProps): ReactNode { const { children, portalKey } = props; const [container, setContainer] = useState(null); diff --git a/src/react/use-drag-and-drop.ts b/src/react/use-drag-and-drop.ts index d53fd66..7738c3d 100644 --- a/src/react/use-drag-and-drop.ts +++ b/src/react/use-drag-and-drop.ts @@ -1,4 +1,4 @@ -import { type RefObject, type DependencyList, type MutableRefObject, useMemo } from 'react'; +import { type RefObject, type DependencyList, useMemo } from 'react'; import { type Point2d, Vector2 } from '../math/mod.ts'; import { getPositionedParentOffset } from '../dom/mod.ts'; import { useIsomorphicLayoutEffect } from '../react/use-isomorphic-layout-effect.ts'; @@ -77,13 +77,7 @@ function canStartDragDefault(event: TouchEvent | PointerEvent | MouseEvent): boo * @param options Options. */ export function useDragAndDrop( - ref: - | RefObject - | RefObject - | RefObject - | MutableRefObject - | MutableRefObject - | MutableRefObject, + ref: RefObject | RefObject | RefObject, { strategy = 'absolute', disabled, diff --git a/src/react/use-intersection.ts b/src/react/use-intersection.ts index eb4eaf0..1f84c1d 100644 --- a/src/react/use-intersection.ts +++ b/src/react/use-intersection.ts @@ -1,11 +1,4 @@ -import { - type RefObject, - type MutableRefObject, - useContext, - useMemo, - useRef, - type DependencyList, -} from 'react'; +import { type RefObject, useContext, useMemo, useRef, type DependencyList } from 'react'; import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.ts'; import { useLatestRef } from './use-latest-ref.ts'; import { IntersectionObserverContext } from './context/intersection-observer-context.ts'; @@ -24,13 +17,7 @@ export interface UseIntersectionOptions extends IntersectionObserverInit { * @param options Observe options. */ export function useIntersection( - ref: - | RefObject - | RefObject - | RefObject - | MutableRefObject - | MutableRefObject - | MutableRefObject, + ref: RefObject | RefObject | RefObject, callback: (entry: IntersectionObserverEntry) => void, { extraDeps = zeroDeps, ...options }: UseIntersectionOptions = {}, ): void { diff --git a/src/react/use-latest-ref.ts b/src/react/use-latest-ref.ts index 292e83f..cd251a8 100644 --- a/src/react/use-latest-ref.ts +++ b/src/react/use-latest-ref.ts @@ -1,4 +1,4 @@ -import { type MutableRefObject, useRef } from 'react'; +import { type RefObject, useRef } from 'react'; /** * Returns ref that automatically actualizes current value each render. @@ -10,7 +10,7 @@ import { type MutableRefObject, useRef } from 'react'; * @param value Current value. * @returns Ref object. */ -export function useLatestRef(value: T): MutableRefObject { +export function useLatestRef(value: T): RefObject { const ref = useRef(value); // immediately update value if it is not equals to current diff --git a/src/react/use-merge-refs.ts b/src/react/use-merge-refs.ts index 130d1d9..effdbbc 100644 --- a/src/react/use-merge-refs.ts +++ b/src/react/use-merge-refs.ts @@ -1,8 +1,8 @@ -import { type Ref, type RefCallback, type RefObject, type MutableRefObject, useRef } from 'react'; +import { type Ref, type RefCallback, type RefObject, useRef } from 'react'; import { mergeRefs } from './merge-refs.ts'; interface HookState { - refs: Array | RefObject | RefCallback | MutableRefObject | null | undefined>; + refs: Array | RefObject | RefCallback | null | undefined>; merged: Ref; } @@ -12,7 +12,7 @@ interface HookState { * @returns Merged ref. */ export function useMergeRefs( - refs: Array | RefObject | RefCallback | MutableRefObject | null | undefined>, + refs: Array | RefObject | RefCallback | null | undefined>, ): Ref { const stateRef = useRef>(null); diff --git a/src/react/use-resize.ts b/src/react/use-resize.ts index f76d45a..328b89c 100644 --- a/src/react/use-resize.ts +++ b/src/react/use-resize.ts @@ -1,10 +1,4 @@ -import { - type RefObject, - type MutableRefObject, - useContext, - useMemo, - type DependencyList, -} from 'react'; +import { type RefObject, useContext, useMemo, type DependencyList } from 'react'; import { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.ts'; import { useLatestRef } from './use-latest-ref.ts'; import { ResizeObserverContext } from './context/resize-observer-context.ts'; @@ -22,13 +16,7 @@ export interface UseResizeOptions extends ResizeObserverOptions { * @param options Resize observer options. */ export function useResize( - ref: - | RefObject - | RefObject - | RefObject - | MutableRefObject - | MutableRefObject - | MutableRefObject, + ref: RefObject | RefObject | RefObject, callback: (entry: ResizeObserverEntry) => void, { extraDeps = zeroDeps, ...options }: UseResizeOptions = {}, ): void {