Skip to content

Commit 65010be

Browse files
committed
refactor: Improve TypeScript type safety by replacing 'any' with explicit types in tests, components, and web vitals reporting.
1 parent 2eec337 commit 65010be

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/reportWebVitals.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { onCLS, onFCP, onLCP, onTTFB } from "web-vitals";
2+
import type { Metric } from "web-vitals";
23

3-
const reportWebVitals = (onPerfEntry?: any) => {
4+
const reportWebVitals = (onPerfEntry?: (metric: Metric) => void) => {
45
if (onPerfEntry && onPerfEntry instanceof Function) {
56
import("web-vitals").then(() => {
67
onCLS(onPerfEntry);

src/services/urlBuilder.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
```typescript
12
import { useUrlBuilder } from "./urlBuilder";
23

34
// Mock window.location for the test
45
const originalLocation = window.location;
5-
delete window.location;
6+
delete (window as Partial<Window>).location;
67
window.location = {
78
origin: "http://localhost",
89
search: "?query=123",
9-
} as any;
10+
} as Location;
1011

1112
describe("useUrlBuilder", () => {
1213
afterAll(() => {

src/views/SessionFeedback/SessionFeedback.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ const SessionFeedback: FC<React.PropsWithChildren<unknown>> = () => {
4040
);
4141

4242
const [globalFilterValue, setGlobalFilterValue] = React.useState("");
43-
const [filters, setFilters] = React.useState({
43+
const [filters, setFilters] = React.useState<{
44+
global: { value: string | null; matchMode: FilterMatchMode };
45+
}>({
4446
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
4547
});
4648

47-
const onGlobalFilterChange = (e: { target: { value: any } }) => {
49+
const onGlobalFilterChange = (e: React.ChangeEvent<HTMLInputElement>) => {
4850
const value = e.target.value;
4951
const _filters = { ...filters };
5052

0 commit comments

Comments
 (0)