Skip to content

Commit 076000d

Browse files
committed
fix(mobile): resolve all high priority type safety issues
1 parent 595fd91 commit 076000d

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

apps/mobile/v1/src/components/settings/UsageBottomSheet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
BottomSheetView,
66
BottomSheetBackdrop,
77
BottomSheetScrollView,
8+
BottomSheetBackdropProps,
89
} from '@gorhom/bottom-sheet';
910
import { Ionicons } from '@expo/vector-icons';
1011
import { useApiService, type ApiUserUsage } from '@/src/services/api';
@@ -50,7 +51,7 @@ export function UsageBottomSheet({ sheetRef, snapPoints }: UsageBottomSheetProps
5051
};
5152

5253
const renderBackdrop = React.useCallback(
53-
(props: any) => (
54+
(props: BottomSheetBackdropProps) => (
5455
<BottomSheetBackdrop
5556
{...props}
5657
disappearsOnIndex={-1}

apps/mobile/v1/src/lib/logger.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55

66
import { Platform } from 'react-native';
77

8-
let NewRelic: any = null;
8+
/**
9+
* Type definitions for New Relic SDK
10+
* Based on newrelic-react-native-agent API
11+
*/
12+
interface NewRelicSDK {
13+
setUserId?: (userId: string) => void;
14+
setAttribute?: (name: string, value: string | number | boolean) => void;
15+
recordError?: (error: Error) => void;
16+
logDebug?: (message: string, attributes?: Record<string, unknown>) => void;
17+
logInfo?: (message: string, attributes?: Record<string, unknown>) => void;
18+
logWarning?: (message: string, attributes?: Record<string, unknown>) => void;
19+
logError?: (message: string, attributes?: Record<string, unknown>) => void;
20+
recordCustomEvent?: (eventName: string, attributes?: Record<string, unknown>) => void;
21+
recordBreadcrumb?: (name: string, attributes?: Record<string, unknown>) => void;
22+
}
23+
24+
let NewRelic: NewRelicSDK | null = null;
925

1026
// Initialize New Relic reference
1127
try {
@@ -24,7 +40,7 @@ export enum LogLevel {
2440

2541
interface LogOptions {
2642
/** Additional attributes to attach to the log */
27-
attributes?: Record<string, any>;
43+
attributes?: Record<string, unknown>;
2844
/** Whether to only send to New Relic (skip console) */
2945
newRelicOnly?: boolean;
3046
}
@@ -35,7 +51,7 @@ interface LogOptions {
3551
class Logger {
3652
private isNewRelicAvailable: boolean;
3753
private userId: string | null = null;
38-
private sessionAttributes: Record<string, any> = {};
54+
private sessionAttributes: Record<string, unknown> = {};
3955

4056
constructor() {
4157
this.isNewRelicAvailable = NewRelic !== null;
@@ -57,7 +73,7 @@ class Logger {
5773
/**
5874
* Set session-level attributes that will be included in all logs
5975
*/
60-
setSessionAttributes(attributes: Record<string, any>): void {
76+
setSessionAttributes(attributes: Record<string, unknown>): void {
6177
this.sessionAttributes = { ...this.sessionAttributes, ...attributes };
6278

6379
// Set each attribute in New Relic
@@ -197,7 +213,7 @@ class Logger {
197213
/**
198214
* Record a custom event in New Relic
199215
*/
200-
recordEvent(eventName: string, attributes?: Record<string, any>): void {
216+
recordEvent(eventName: string, attributes?: Record<string, unknown>): void {
201217
if (this.isNewRelicAvailable && NewRelic.recordCustomEvent) {
202218
NewRelic.recordCustomEvent(eventName, attributes);
203219
}
@@ -223,7 +239,7 @@ class Logger {
223239
/**
224240
* Record a breadcrumb (useful for tracking user flow)
225241
*/
226-
breadcrumb(name: string, attributes?: Record<string, any>): void {
242+
breadcrumb(name: string, attributes?: Record<string, unknown>): void {
227243
if (this.isNewRelicAvailable && NewRelic.recordBreadcrumb) {
228244
NewRelic.recordBreadcrumb(name, attributes);
229245
}

apps/mobile/v1/src/screens/FoldersScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useTheme } from '../theme';
88
import { Ionicons } from '@expo/vector-icons';
99
import { useApiService, type Folder } from '../services/api';
1010
import { FOLDER_CARD, ACTION_BUTTON, FOLDER_COLORS } from '../constants/ui';
11-
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput } from '@gorhom/bottom-sheet';
11+
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
1212

1313
// Special views configuration matching web app
1414
const SPECIAL_VIEWS = [
@@ -74,7 +74,7 @@ export default function FoldersScreen() {
7474

7575
// Backdrop component
7676
const renderBackdrop = useCallback(
77-
(props: any) => (
77+
(props: BottomSheetBackdropProps) => (
7878
<BottomSheetBackdrop
7979
{...props}
8080
disappearsOnIndex={-1}

apps/mobile/v1/src/screens/NotesListScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useTheme } from '../theme';
77
import { useApiService, type Note, type Folder } from '../services/api';
88
import { Ionicons } from '@expo/vector-icons';
99
import { NOTE_CARD, FOLDER_CARD, SECTION, FOLDER_COLORS } from '../constants/ui';
10-
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput } from '@gorhom/bottom-sheet';
10+
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
1111

1212
interface RouteParams {
1313
folderId?: string;
@@ -81,7 +81,7 @@ export default function NotesListScreen({ navigation, route, renderHeader, scrol
8181

8282
// Backdrop component
8383
const renderBackdrop = useCallback(
84-
(props: any) => (
84+
(props: BottomSheetBackdropProps) => (
8585
<BottomSheetBackdrop
8686
{...props}
8787
disappearsOnIndex={-1}

apps/mobile/v1/src/screens/SettingsScreen.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import { Card } from '../components/ui/Card';
99
import { Ionicons } from '@expo/vector-icons';
1010
import { clearUserEncryptionData } from '../lib/encryption';
1111
import { forceGlobalMasterPasswordRefresh } from '../hooks/useMasterPassword';
12-
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetScrollView } from '@gorhom/bottom-sheet';
12+
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetScrollView, BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
1313
import AsyncStorage from '@react-native-async-storage/async-storage';
1414
import { APP_VERSION } from '../constants/version';
1515
import { UsageBottomSheet } from '../components/settings/UsageBottomSheet';
1616

17+
// Type for valid Ionicons names
18+
type IconName = keyof typeof Ionicons.glyphMap;
19+
1720
interface Props {
1821
onLogout?: () => void;
1922
}
@@ -45,7 +48,7 @@ export default function SettingsScreen({ onLogout }: Props) {
4548

4649
// Backdrop component
4750
const renderBackdrop = useCallback(
48-
(props: any) => (
51+
(props: BottomSheetBackdropProps) => (
4952
<BottomSheetBackdrop
5053
{...props}
5154
disappearsOnIndex={-1}
@@ -288,7 +291,7 @@ export default function SettingsScreen({ onLogout }: Props) {
288291
}
289292
]}>
290293
<Ionicons
291-
name={item.icon as any}
294+
name={item.icon as IconName}
292295
size={20}
293296
color={theme.colors.foreground}
294297
/>
@@ -370,12 +373,12 @@ export default function SettingsScreen({ onLogout }: Props) {
370373
key={option.mode}
371374
style={[styles.optionItem, { backgroundColor: theme.colors.card, borderColor: theme.colors.border }]}
372375
onPress={() => {
373-
theme.setThemeMode(option.mode as any);
376+
theme.setThemeMode(option.mode);
374377
themeModeSheetRef.current?.dismiss();
375378
}}
376379
>
377380
<View style={[styles.optionIcon, { backgroundColor: theme.colors.muted }]}>
378-
<Ionicons name={option.icon as any} size={20} color={theme.colors.foreground} />
381+
<Ionicons name={option.icon as IconName} size={20} color={theme.colors.foreground} />
379382
</View>
380383
<View style={styles.optionText}>
381384
<Text style={[styles.optionTitle, { color: theme.colors.foreground }]}>
@@ -436,7 +439,7 @@ export default function SettingsScreen({ onLogout }: Props) {
436439
{ backgroundColor: theme.colors.card, borderColor: theme.colors.border }
437440
]}
438441
onPress={() => {
439-
theme.setLightTheme(preset.id as any);
442+
theme.setLightTheme(preset.id);
440443
}}
441444
>
442445
<View style={[styles.colorPreview, {
@@ -476,7 +479,7 @@ export default function SettingsScreen({ onLogout }: Props) {
476479
{ backgroundColor: theme.colors.card, borderColor: theme.colors.border }
477480
]}
478481
onPress={() => {
479-
theme.setDarkTheme(preset.id as any);
482+
theme.setDarkTheme(preset.id);
480483
}}
481484
>
482485
<View style={[styles.colorPreview, {
@@ -623,7 +626,7 @@ export default function SettingsScreen({ onLogout }: Props) {
623626
}}
624627
>
625628
<View style={[styles.optionIcon, { backgroundColor: theme.colors.muted }]}>
626-
<Ionicons name={option.icon as any} size={20} color={theme.colors.foreground} />
629+
<Ionicons name={option.icon as IconName} size={20} color={theme.colors.foreground} />
627630
</View>
628631
<View style={styles.optionText}>
629632
<Text style={[styles.optionTitle, { color: theme.colors.foreground }]}>

apps/mobile/v1/src/services/api/utils/pagination.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ interface PaginationResponse<T> {
1111
total: number;
1212
limit: number;
1313
page: number;
14-
totalPages: number;
14+
totalPages?: number;
15+
pages?: number; // Some APIs use 'pages' instead of 'totalPages'
1516
};
1617
total?: number;
1718
limit?: number;
@@ -68,9 +69,9 @@ function determineHasMorePages<T>(
6869

6970
// Check for pagination object
7071
if (resp.pagination) {
71-
const { page, totalPages, pages } = resp.pagination as any;
72-
// API uses 'pages' not 'totalPages'
73-
const total = totalPages || pages;
72+
const { page, totalPages, pages } = resp.pagination;
73+
// API uses 'pages' not 'totalPages', so check both
74+
const total = totalPages ?? pages;
7475
if (total !== undefined) {
7576
return page < total;
7677
}

0 commit comments

Comments
 (0)