diff --git a/services/console/src/components/auth/AuthOAuth.tsx b/services/console/src/components/auth/AuthOAuth.tsx index 654b8b34ef..b0841e890d 100644 --- a/services/console/src/components/auth/AuthOAuth.tsx +++ b/services/console/src/components/auth/AuthOAuth.tsx @@ -81,7 +81,11 @@ const AuthOAuth = (props: Props) => { ); }); }; - const [_jsonAuthUser] = createResource(fetcher, getAuthUser); + const [_jsonAuthUser] = createResource< + // biome-ignore lint/suspicious/noConfusingVoidType: getAuthUser navigates and returns nothing + void | null, + ReturnType + >(fetcher, getAuthUser); return <>; }; diff --git a/services/console/src/components/auth/AuthRedirect.tsx b/services/console/src/components/auth/AuthRedirect.tsx index d33a2ced7e..c4420b40c4 100644 --- a/services/console/src/components/auth/AuthRedirect.tsx +++ b/services/console/src/components/auth/AuthRedirect.tsx @@ -1,11 +1,6 @@ import * as Sentry from "@sentry/astro"; import { Show, createMemo, createResource } from "solid-js"; -import type { - JsonAccept, - JsonAuthAck, - JsonAuthUser, - JsonOrganization, -} from "../../types/bencher"; +import type { JsonAccept, JsonAuthUser } from "../../types/bencher"; import { authUser } from "../../util/auth"; import { httpPost } from "../../util/http"; import { NotifyKind, navigateNotify } from "../../util/notify"; @@ -57,7 +52,11 @@ const AuthRedirect = (props: { apiUrl?: string; path: string }) => { ); }); }; - const [_jsonAuth] = createResource(acceptFetcher, acceptInvite); + const [_jsonAuth] = createResource< + // biome-ignore lint/suspicious/noConfusingVoidType: acceptInvite navigates and returns nothing + void | null, + ReturnType + >(acceptFetcher, acceptInvite); const claimFetcher = createMemo(() => { return { @@ -97,10 +96,11 @@ const AuthRedirect = (props: { apiUrl?: string; path: string }) => { ); }); }; - const [_jsonOrganization] = createResource( - claimFetcher, - claimProject, - ); + const [_jsonOrganization] = createResource< + // biome-ignore lint/suspicious/noConfusingVoidType: claimProject navigates and returns nothing + void | null, + ReturnType + >(claimFetcher, claimProject); return ( { return null; }); }; - const [usage, { refetch }] = createResource( - fetcher, - fetchPlan, - ); + const [usage, { refetch }] = createResource< + null | JsonUsage, + ReturnType + >(fetcher, fetchPlan); return ( { return; }); }; - const [organizations] = createResource( - orgsFetcher, - getOrganizations, - ); + const [organizations] = createResource< + undefined | JsonOrganization[], + ReturnType + >(orgsFetcher, getOrganizations); const organization = createMemo(() => { const orgs = organizations(); @@ -178,10 +178,10 @@ const OnboardInvite = (props: Props) => { return null; }); }; - const [_invite] = createResource( - inviteFetcher, - postInvite, - ); + const [_invite] = createResource< + undefined | JsonAuthAck, + ReturnType + >(inviteFetcher, postInvite); return ( <> diff --git a/services/console/src/components/console/onboard/OnboardKey.tsx b/services/console/src/components/console/onboard/OnboardKey.tsx index 0cd32d1e9d..27eee79c77 100644 --- a/services/console/src/components/console/onboard/OnboardKey.tsx +++ b/services/console/src/components/console/onboard/OnboardKey.tsx @@ -83,10 +83,10 @@ const OnboardKey = (props: Props) => { return; }); }; - const [organizations] = createResource( - orgsFetcher, - getOrganizations, - ); + const [organizations] = createResource< + undefined | JsonOrganization[], + ReturnType + >(orgsFetcher, getOrganizations); const organization = createMemo(() => { const orgs = organizations(); @@ -129,10 +129,10 @@ const OnboardKey = (props: Props) => { return; }); }; - const [projects] = createResource( - projectsFetcher, - getProjects, - ); + const [projects] = createResource< + undefined | JsonProject[], + ReturnType + >(projectsFetcher, getProjects); const project = createMemo(() => { const orgProjects = projects(); @@ -174,10 +174,10 @@ const OnboardKey = (props: Props) => { return; }); }; - const [apiKeys] = createResource( - keysFetcher, - getKeys, - ); + const [apiKeys] = createResource< + undefined | JsonProjectKey[], + ReturnType + >(keysFetcher, getKeys); const keyFetcher = createMemo(() => { return { @@ -225,7 +225,9 @@ const OnboardKey = (props: Props) => { }); }; const [apiKey] = createResource< - undefined | JsonProjectKey | JsonProjectKeyCreated + // biome-ignore lint/suspicious/noConfusingVoidType: getKey returns early without a value + void | JsonProjectKey | JsonProjectKeyCreated, + ReturnType >(keyFetcher, getKey); const keyValue = createMemo(() => { diff --git a/services/console/src/components/console/onboard/OnboardPlan.tsx b/services/console/src/components/console/onboard/OnboardPlan.tsx index 7f5df753c1..2b9b248123 100644 --- a/services/console/src/components/console/onboard/OnboardPlan.tsx +++ b/services/console/src/components/console/onboard/OnboardPlan.tsx @@ -73,10 +73,10 @@ const OnboardPlan = (props: Props) => { return; }); }; - const [organizations] = createResource( - orgsFetcher, - getOrganizations, - ); + const [organizations] = createResource< + undefined | JsonOrganization[], + ReturnType + >(orgsFetcher, getOrganizations); const organization = createMemo(() => { const orgs = organizations(); diff --git a/services/console/src/components/console/onboard/OnboardProject.tsx b/services/console/src/components/console/onboard/OnboardProject.tsx index 28d9ebc5e6..8077f7c930 100644 --- a/services/console/src/components/console/onboard/OnboardProject.tsx +++ b/services/console/src/components/console/onboard/OnboardProject.tsx @@ -86,10 +86,10 @@ const OnboardProject = (props: Props) => { return; }); }; - const [organizations] = createResource( - orgsFetcher, - getOrganizations, - ); + const [organizations] = createResource< + undefined | JsonOrganization[], + ReturnType + >(orgsFetcher, getOrganizations); const organization = createMemo(() => { const orgs = organizations(); @@ -133,7 +133,8 @@ const OnboardProject = (props: Props) => { }); }; const [projects, { refetch: refetchProjects }] = createResource< - undefined | JsonProject[] + undefined | JsonProject[], + ReturnType >(projectsFetcher, getProjects); const organizationProject = createMemo(() => { @@ -186,10 +187,10 @@ const OnboardProject = (props: Props) => { return; }); }; - const [project] = createResource( - projectFetcher, - getProject, - ); + const [project] = createResource< + undefined | JsonProject, + ReturnType + >(projectFetcher, getProject); const [renameProject, setRenameProject] = createSignal(null); const [renameValid, setRenameValid] = createSignal(null); @@ -255,10 +256,10 @@ const OnboardProject = (props: Props) => { return; }); }; - const [_updatedProject] = createResource( - updateProjectFetcher, - updateProject, - ); + const [_updatedProject] = createResource< + undefined | JsonProject, + ReturnType + >(updateProjectFetcher, updateProject); return ( <> diff --git a/services/console/src/components/console/onboard/OnboardRun.tsx b/services/console/src/components/console/onboard/OnboardRun.tsx index 1219a36f5a..e577dd419e 100644 --- a/services/console/src/components/console/onboard/OnboardRun.tsx +++ b/services/console/src/components/console/onboard/OnboardRun.tsx @@ -79,10 +79,10 @@ const OnboardRun = (props: Props) => { return null; }); }; - const [organizations] = createResource( - orgsFetcher, - getOrganizations, - ); + const [organizations] = createResource< + null | JsonOrganization[], + ReturnType + >(orgsFetcher, getOrganizations); const organization = createMemo(() => { const orgs = organizations(); @@ -134,10 +134,10 @@ const OnboardRun = (props: Props) => { return null; }); }; - const [projects] = createResource( - projectsFetcher, - getProjects, - ); + const [projects] = createResource< + null | JsonProject[], + ReturnType + >(projectsFetcher, getProjects); const runCode = createMemo(() => { const orgProjects = projects(); diff --git a/services/console/src/components/console/perf/PerfPanel.tsx b/services/console/src/components/console/perf/PerfPanel.tsx index 6bb1c63513..eb1b10ee0a 100644 --- a/services/console/src/components/console/perf/PerfPanel.tsx +++ b/services/console/src/components/console/perf/PerfPanel.tsx @@ -746,29 +746,29 @@ const PerfPanel = (props: Props) => { token: user?.token, }; }); - const [plot_selected] = createResource( - selectedPlotFetcher, - async (fetcher) => { - if ( - !fetcher.bencher_valid || - !fetcher.plot || - !fetcher.project_slug || - fetcher.project_slug === "undefined" || - (props.isConsole && !validJwt(fetcher.token)) || - props.isEmbed === true - ) { + const [plot_selected] = createResource< + JsonPlot[], + ReturnType + >(selectedPlotFetcher, async (fetcher) => { + if ( + !fetcher.bencher_valid || + !fetcher.plot || + !fetcher.project_slug || + fetcher.project_slug === "undefined" || + (props.isConsole && !validJwt(fetcher.token)) || + props.isEmbed === true + ) { + return []; + } + const path = `/v0/projects/${fetcher.project_slug}/plots/${fetcher.plot}`; + return await httpGet(props.apiUrl, path, fetcher.token) + .then((resp) => [resp?.data as JsonPlot]) + .catch((error) => { + console.error(error); + Sentry.captureException(error); return []; - } - const path = `/v0/projects/${fetcher.project_slug}/plots/${fetcher.plot}`; - return await httpGet(props.apiUrl, path, fetcher.token) - .then((resp) => [resp?.data as JsonPlot]) - .catch((error) => { - console.error(error); - Sentry.captureException(error); - return []; - }); - }, - ); + }); + }); // Drop only the pinned plot association; the rest of the view is untouched. const handlePlotSelected = () => { setSearchParams({ @@ -863,19 +863,19 @@ const PerfPanel = (props: Props) => { } return undefined; }); - const [first_report_data] = createResource( - first_report_fetcher, - async (uuid) => { - const path = `/v0/projects/${project_slug()}/reports/${uuid}`; - return await httpGet(props.apiUrl, path, user?.token) - .then((resp) => resp?.data) - .catch((error) => { - console.error(error); - Sentry.captureException(error); - return undefined; - }); - }, - ); + const [first_report_data] = createResource< + undefined | JsonReport, + ReturnType + >(first_report_fetcher, async (uuid) => { + const path = `/v0/projects/${project_slug()}/reports/${uuid}`; + return await httpGet(props.apiUrl, path, user?.token) + .then((resp) => resp?.data) + .catch((error) => { + console.error(error); + Sentry.captureException(error); + return undefined; + }); + }); createEffect(() => { const data = reports_data(); if (data) { diff --git a/services/console/src/components/console/perf/header/UpdateModal.tsx b/services/console/src/components/console/perf/header/UpdateModal.tsx index 50c3c38154..a4c8a1ce66 100644 --- a/services/console/src/components/console/perf/header/UpdateModal.tsx +++ b/services/console/src/components/console/perf/header/UpdateModal.tsx @@ -74,25 +74,25 @@ const UpdateModal = (props: Props) => { token: props.user?.token, }; }); - const [plots_list] = createResource( - plotsFetcher, - async (fetcher) => { - if (!fetcher.project || !fetcher.plot) { + const [plots_list] = createResource< + JsonPlot[], + ReturnType + >(plotsFetcher, async (fetcher) => { + if (!fetcher.project || !fetcher.plot) { + return []; + } + return await httpGet( + props.apiUrl, + `/v0/projects/${fetcher.project}/plots?per_page=${MAX_PLOTS}`, + fetcher.token, + ) + .then((resp) => resp?.data as JsonPlot[]) + .catch((error) => { + console.error(error); + Sentry.captureException(error); return []; - } - return await httpGet( - props.apiUrl, - `/v0/projects/${fetcher.project}/plots?per_page=${MAX_PLOTS}`, - fetcher.token, - ) - .then((resp) => resp?.data as JsonPlot[]) - .catch((error) => { - console.error(error); - Sentry.captureException(error); - return []; - }); - }, - ); + }); + }); const position = createMemo(() => { const index = (plots_list() ?? []).findIndex( (list_plot) => list_plot.uuid === props.plot(), diff --git a/services/console/src/components/console/plots/Pinned.tsx b/services/console/src/components/console/plots/Pinned.tsx index 7beed8a8a2..8df71d8e3b 100644 --- a/services/console/src/components/console/plots/Pinned.tsx +++ b/services/console/src/components/console/plots/Pinned.tsx @@ -79,7 +79,10 @@ const Pinned = (props: { return fetcher.plot; }); }; - const [plot] = createResource(plotFetcher, getPlot); + const [plot] = createResource>( + plotFetcher, + getPlot, + ); return ( (rankFetcher, patchRank); + const [_rank] = createResource>( + rankFetcher, + patchRank, + ); return (