From 12754bd0aa5c1971b231920c136c3d6367762bff Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Mon, 4 Nov 2024 18:13:10 -0500 Subject: [PATCH] fix: resolve type errors across the codebase --- app/components/Toaster.tsx | 14 ++++++--- app/routes/_data.acls._index/route.tsx | 29 ++++++++++++------- .../_data.machines._index/dialogs/new.tsx | 2 +- app/routes/_data.settings._index/route.tsx | 5 +--- .../dialogs/new.tsx | 4 +-- .../_data.settings.auth-keys._index/key.tsx | 2 +- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/app/components/Toaster.tsx b/app/components/Toaster.tsx index a83d34f..b523fbc 100644 --- a/app/components/Toaster.tsx +++ b/app/components/Toaster.tsx @@ -1,7 +1,7 @@ import { XIcon } from '@primer/octicons-react' -import { type AriaToastProps, useToast, useToastRegion } from '@react-aria/toast' -import { ToastQueue, type ToastState, useToastQueue } from '@react-stately/toast' -import { type ReactNode, useRef } from 'react' +import { AriaToastProps, useToast, useToastRegion } from '@react-aria/toast' +import { ToastQueue, ToastState, useToastQueue } from '@react-stately/toast' +import { ReactNode, useRef } from 'react' import { Button } from 'react-aria-components' import { createPortal } from 'react-dom' import { ClientOnly } from 'remix-utils/client-only' @@ -14,6 +14,8 @@ type ToastProperties = AriaToastProps & { function Toast({ state, ...properties }: ToastProperties) { const reference = useRef(null) + + // @ts-expect-error: RefObject doesn't map to FocusableElement? const { toastProps, titleProps, closeButtonProps } = useToast(properties, state, reference) return ( @@ -52,11 +54,15 @@ export function toast(text: string) { export function Toaster() { const reference = useRef(null) const state = useToastQueue(toasts) + + // @ts-expect-error: React 19 has weird types for Portal vs Node const { regionProps } = useToastRegion({}, state, reference) return ( - {() => createPortal( + { + // @ts-expect-error: Portal doesn't match Node in React 19 yet + () => createPortal( state.visibleToasts.length >= 0 ? (
- {fetcher.data?.success === false + { + // @ts-ignore: useDebounceFetcher is not typed correctly + fetcher.data?.success === false ? ( + // @ts-ignore: useDebounceFetcher is not typed correctly ) : undefined} @@ -291,7 +300,7 @@ export default function Page() { @@ -335,13 +344,13 @@ export default function Page() { - ) : } + ) : }
) } diff --git a/app/routes/_data.machines._index/dialogs/new.tsx b/app/routes/_data.machines._index/dialogs/new.tsx index dd35dc9..429beba 100644 --- a/app/routes/_data.machines._index/dialogs/new.tsx +++ b/app/routes/_data.machines._index/dialogs/new.tsx @@ -18,7 +18,7 @@ export interface NewProps { } export default function New(data: NewProps) { - const fetcher = useFetcher() + const fetcher = useFetcher<{ success?: boolean }>() const mkeyState = useState(false) const [mkey, setMkey] = useState('') const [user, setUser] = useState('') diff --git a/app/routes/_data.settings._index/route.tsx b/app/routes/_data.settings._index/route.tsx index 920db35..6a4e825 100644 --- a/app/routes/_data.settings._index/route.tsx +++ b/app/routes/_data.settings._index/route.tsx @@ -31,10 +31,7 @@ export default function Page() {

- + { setReusable(!reusable) }} /> - +
@@ -121,7 +121,7 @@ export default function AddPreAuthKey(data: Props) { }} />
- +
{ + onPress={async () => { await navigator.clipboard.writeText( `tailscale up --login-server ${server} --authkey ${authKey.key}` )