diff --git a/src/components/BackendList.tsx b/src/components/BackendList.tsx index e4f4d80..9ad833c 100644 --- a/src/components/BackendList.tsx +++ b/src/components/BackendList.tsx @@ -110,8 +110,6 @@ function Item({ {secret ? ( <> {show ? secret : '***'} - - {/* @ts-expect-error ts-migrate(2322) FIXME: Type 'boolean | (() => void)' is not assignable to... Remove this comment to see the full error message */} diff --git a/src/components/Collapsible.tsx b/src/components/Collapsible.tsx index 819bc7c..65284cd 100644 --- a/src/components/Collapsible.tsx +++ b/src/components/Collapsible.tsx @@ -1,17 +1,18 @@ -import React from 'react'; +import type { MutableRefObject } from 'react'; +import * as React from 'react'; import ResizeObserver from 'resize-observer-polyfill'; import { framerMotionResouce } from '../misc/motion'; const { memo, useState, useRef, useEffect } = React; -function usePrevious(value) { +function usePrevious(value: any) { const ref = useRef(); useEffect(() => void (ref.current = value), [value]); return ref.current; } -function useMeasure() { +function useMeasure(): [MutableRefObject, { height: number }] { const ref = useRef(); const [bounds, set] = useState({ height: 0 }); useEffect(() => { @@ -27,7 +28,7 @@ const variantsCollpapsibleWrap = { height: 'auto', transition: { duration: 0 }, }, - open: (height) => ({ + open: (height: number) => ({ height, opacity: 1, visibility: 'visible', @@ -50,12 +51,12 @@ const variantsCollpapsibleChildContainer = { }, }; -// @ts-expect-error ts-migrate(2339) FIXME: Property 'isOpen' does not exist on type '{ childr... Remove this comment to see the full error message -const Collapsible = memo(({ children, isOpen }) => { +type CollapsibleProps = { children: React.ReactNode; isOpen?: boolean }; + +const Collapsible = memo(({ children, isOpen }: CollapsibleProps) => { const module = framerMotionResouce.read(); const motion = module.motion; const previous = usePrevious(isOpen); - // @ts-expect-error ts-migrate(2339) FIXME: Property 'height' does not exist on type 'MutableR... Remove this comment to see the full error message const [refToMeature, { height }] = useMeasure(); return (
diff --git a/src/components/Connections.tsx b/src/components/Connections.tsx index 435345b..c72f489 100644 --- a/src/components/Connections.tsx +++ b/src/components/Connections.tsx @@ -109,7 +109,7 @@ function renderTableOrPlaceholder(conns: FormattedConn[]) { ); } -function ConnQty({ qty }) { +function connQty({ qty }) { return qty < 100 ? '' + qty : '99+'; } @@ -179,17 +179,11 @@ function Conn({ apiConfig }) { {t('Active')} - - {/* @ts-expect-error ts-migrate(2786) FIXME: 'ConnQty' cannot be used as a JSX component. */} - - + {connQty({ qty: filteredConns.length })} {t('Closed')} - - {/* @ts-expect-error ts-migrate(2786) FIXME: 'ConnQty' cannot be used as a JSX component. */} - - + {connQty({ qty: filteredClosedConns.length })}
diff --git a/src/components/Rules.tsx b/src/components/Rules.tsx index e6e1422..ad630b5 100644 --- a/src/components/Rules.tsx +++ b/src/components/Rules.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { useTranslation } from 'react-i18next'; import { areEqual, VariableSizeList } from 'react-window'; import { RuleProviderItem } from 'src/components/rules/RuleProviderItem'; @@ -7,7 +7,7 @@ import { RulesPageFab } from 'src/components/rules/RulesPageFab'; import { TextFilter } from 'src/components/shared/TextFitler'; import { ruleFilterText } from 'src/store/rules'; import { State } from 'src/store/types'; -import { ClashAPIConfig } from 'src/types'; +import { ClashAPIConfig, RuleType } from 'src/types'; import useRemainingViewPortHeight from '../hooks/useRemainingViewPortHeight'; import { getClashAPIConfig } from '../store/app'; @@ -48,8 +48,17 @@ function getItemSizeFactory({ provider }) { }; } -// @ts-expect-error ts-migrate(2339) FIXME: Property 'index' does not exist on type '{ childre... Remove this comment to see the full error message -const Row = memo(({ index, style, data }) => { +type RowProps = { + index: number; + style: React.CSSProperties; + data: { + apiConfig: ClashAPIConfig; + rules: RuleType[]; + provider: { names: string[]; byName: any }; + }; +}; + +const Row = memo(({ index, style, data }: RowProps) => { const { rules, provider, apiConfig } = data; const providerQty = provider.names.length; diff --git a/src/components/StyleGuide.tsx b/src/components/StyleGuide.tsx index ee38697..1f5f3be 100644 --- a/src/components/StyleGuide.tsx +++ b/src/components/StyleGuide.tsx @@ -21,7 +21,9 @@ const optionsRule = [ { label: 'Direct', value: 'Direct' }, ]; -const Pane = ({ children, style }) =>
{children}
; +const Pane = ({ children, style }: { children: React.ReactNode; style?: React.CSSProperties }) => ( +
{children}
+); function useToggle(initialState = false) { const [onoff, setonoff] = React.useState(initialState); @@ -40,19 +42,15 @@ class StyleGuide extends PureComponent { render() { return (
- {/* @ts-expect-error ts-migrate(2741) FIXME: Property 'style' is missing in type '{ children: E... Remove this comment to see the full error message */} - {/* @ts-expect-error ts-migrate(2741) FIXME: Property 'style' is missing in type '{ children: E... Remove this comment to see the full error message */} - {/* @ts-expect-error ts-migrate(2741) FIXME: Property 'style' is missing in type '{ children: E... Remove this comment to see the full error message */} - {/* @ts-expect-error ts-migrate(2741) FIXME: Property 'style' is missing in type '{ children: E... Remove this comment to see the full error message */}