Skip to content

Commit 3019bec

Browse files
Remove @ts-nocheck from frontend files to ensure app is fully typechecked (#1530)
Noticed some errors during runtime testing of another PR that should have been caught by typescript. This fixes reduces the chances of that slipping through CI
1 parent 39633f3 commit 3019bec

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

packages/app/src/AuthPage.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// @ts-nocheck TODO: remove this line
2-
31
import { useEffect } from 'react';
42
import Link from 'next/link';
53
import { useRouter } from 'next/router';
64
import { NextSeo } from 'next-seo';
7-
import cx from 'classnames';
5+
import { HTTPError } from 'ky';
86
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
97
import {
108
Button,
@@ -92,17 +90,18 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) {
9290
{
9391
onSuccess: () => router.push('/search'),
9492
onError: async error => {
95-
const jsonData = await error.response.json();
93+
if (error instanceof HTTPError) {
94+
const jsonData = await error.response.json();
9695

97-
if (Array.isArray(jsonData) && jsonData[0]?.errors?.issues) {
98-
return jsonData[0].errors.issues.forEach((issue: any) => {
99-
setError(issue.path[0], {
100-
type: issue.code,
101-
message: issue.message,
96+
if (Array.isArray(jsonData) && jsonData[0]?.errors?.issues) {
97+
return jsonData[0].errors.issues.forEach((issue: any) => {
98+
setError(issue.path[0], {
99+
type: issue.code,
100+
message: issue.message,
101+
});
102102
});
103-
});
103+
}
104104
}
105-
106105
setError('root', {
107106
type: 'manual',
108107
message: 'An unexpected error occurred, please try again later.',

packages/app/src/LandingHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-nocheck TODO: remove this line
2-
31
import Link from 'next/link';
42
import { Anchor, Burger, Button, Container, Group } from '@mantine/core';
53
import { useDisclosure } from '@mantine/hooks';

packages/app/src/Spotlights.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-nocheck TODO: remove this line
2-
31
import * as React from 'react';
42
import { useRouter } from 'next/router';
53
import { Spotlight, SpotlightActionData } from '@mantine/spotlight';
@@ -11,7 +9,6 @@ import {
119
IconGridDots,
1210
IconHelpCircle,
1311
IconLayout,
14-
IconLayoutSidebar,
1512
IconLogs,
1613
IconSearch,
1714
IconSettings,
@@ -38,28 +35,27 @@ export const useSpotlightActions = () => {
3835
// Saved searches
3936
logViews.forEach(logView => {
4037
logViewActions.push({
41-
id: logView._id,
38+
id: logView.id,
4239
group: 'Saved searches',
4340
leftSection: <IconLogs size={16} />,
44-
description: logView.query,
4541
label: logView.name,
4642
keywords: ['search', 'log', 'saved'],
4743
onClick: () => {
48-
router.push(`/search/${logView._id}`);
44+
router.push(`/search/${logView.id}`);
4945
},
5046
});
5147
});
5248

5349
// Dashboards
5450
dashboards.forEach(dashboard => {
5551
logViewActions.push({
56-
id: dashboard._id,
52+
id: dashboard.id,
5753
group: 'Dashboards',
5854
leftSection: <IconLayout size={16} />,
5955
label: dashboard.name,
6056
keywords: ['dashboard'],
6157
onClick: () => {
62-
router.push(`/dashboards/${dashboard._id}`);
58+
router.push(`/dashboards/${dashboard.id}`);
6359
},
6460
});
6561
});

packages/app/src/api.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { UseQueryOptions } from '@tanstack/react-query';
1010
import { useMutation, useQuery } from '@tanstack/react-query';
1111

1212
import { IS_LOCAL_MODE } from './config';
13+
import { Dashboard } from './dashboard';
1314
import type { AlertsPageItem } from './types';
1415

1516
type ServicesResponse = {
@@ -112,14 +113,14 @@ const api = {
112113
}),
113114
});
114115
},
115-
useDashboards(options?: UseQueryOptions<any, Error>) {
116+
useDashboards(options?: UseQueryOptions<Dashboard[] | null, Error>) {
116117
return useQuery({
117118
queryKey: [`dashboards`],
118119
queryFn: () => {
119120
if (IS_LOCAL_MODE) {
120121
return null;
121122
}
122-
return hdxServer(`dashboards`, { method: 'GET' }).json();
123+
return hdxServer(`dashboards`, { method: 'GET' }).json<Dashboard[]>();
123124
},
124125
...options,
125126
});
@@ -501,8 +502,15 @@ const api = {
501502
},
502503
useRegisterPassword() {
503504
return useMutation({
504-
// @ts-ignore
505-
mutationFn: async ({ email, password, confirmPassword }) =>
505+
mutationFn: async ({
506+
email,
507+
password,
508+
confirmPassword,
509+
}: {
510+
email: string;
511+
password: string;
512+
confirmPassword: string;
513+
}) =>
506514
hdxServer(`register/password`, {
507515
method: 'POST',
508516
json: {

0 commit comments

Comments
 (0)