Skip to content

Commit 595fd91

Browse files
committed
fix(mobile): improve TypeScript type safety across authentication and navigation
1 parent a1183da commit 595fd91

File tree

5 files changed

+61
-26
lines changed

5 files changed

+61
-26
lines changed

apps/mobile/v1/src/components/BottomNavigation.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import { useRouter } from 'expo-router';
55
import { useTheme } from '../theme';
66

77
interface BottomNavigationProps {
8-
navigation?: any;
98
activeTab?: 'folders' | 'add' | 'settings';
109
}
1110

12-
export default function BottomNavigation({ navigation, activeTab = 'folders' }: BottomNavigationProps) {
11+
export default function BottomNavigation({ activeTab = 'folders' }: BottomNavigationProps) {
1312
const theme = useTheme();
1413
const router = useRouter();
1514

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

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ import { Input } from '../components/ui/Input';
2121
import { Ionicons } from '@expo/vector-icons';
2222
import { logger } from '../lib/logger';
2323

24+
/**
25+
* Type definitions for Clerk SDK with legal acceptance fields
26+
* These fields are documented in Clerk but not in the official TypeScript types
27+
*/
28+
interface ClerkSignUpParams {
29+
emailAddress: string;
30+
password: string;
31+
firstName: string;
32+
lastName: string;
33+
legalAccepted?: boolean;
34+
}
35+
36+
interface ClerkUpdateParams {
37+
legalAccepted?: boolean;
38+
legalAcceptedAt?: number;
39+
}
40+
41+
/**
42+
* Type for Clerk error objects
43+
*/
44+
interface ClerkError {
45+
errors?: Array<{ message?: string }>;
46+
}
47+
2448
/**
2549
* Display a toast notification (Android) or log message (iOS)
2650
* @param message - The message to display
@@ -116,14 +140,15 @@ export default function AuthScreen() {
116140
email,
117141
});
118142
}
119-
} catch (err: any) {
143+
} catch (err: unknown) {
144+
const error = err as ClerkError;
120145
logger.error('Sign in failed', err, {
121146
attributes: {
122147
email,
123-
errorMessage: err.errors?.[0]?.message,
148+
errorMessage: error.errors?.[0]?.message,
124149
},
125150
});
126-
showToast(err.errors?.[0]?.message || 'Invalid email or password');
151+
showToast(error.errors?.[0]?.message || 'Invalid email or password');
127152
} finally {
128153
setLoading(false);
129154
}
@@ -145,7 +170,7 @@ export default function AuthScreen() {
145170
firstName,
146171
lastName,
147172
legalAccepted: true, // Required by Clerk Dashboard configuration
148-
} as any);
173+
} as ClerkSignUpParams);
149174

150175
// Send email verification code
151176
await signUp.prepareEmailAddressVerification({ strategy: 'email_code' });
@@ -156,16 +181,17 @@ export default function AuthScreen() {
156181
logger.recordEvent('sign_up_verification_sent', {
157182
email,
158183
});
159-
} catch (err: any) {
184+
} catch (err: unknown) {
185+
const error = err as ClerkError;
160186
logger.error('Sign up failed', err, {
161187
attributes: {
162188
email,
163189
firstName,
164190
lastName,
165-
errorMessage: err.errors?.[0]?.message,
191+
errorMessage: error.errors?.[0]?.message,
166192
},
167193
});
168-
showToast(err.errors?.[0]?.message || 'Unable to create account');
194+
showToast(error.errors?.[0]?.message || 'Unable to create account');
169195
} finally {
170196
setLoading(false);
171197
}
@@ -185,15 +211,18 @@ export default function AuthScreen() {
185211
// Approach 1: Update with legalAccepted field
186212
await signUp.update({
187213
legalAccepted: true,
188-
} as any);
189-
} catch (err1: any) {
214+
} as ClerkUpdateParams);
215+
} catch (err1: unknown) {
190216
try {
191217
// Approach 2: Update with legalAcceptedAt timestamp
192218
await signUp.update({
193219
legalAcceptedAt: new Date().getTime(),
194-
} as any);
195-
} catch (err2: any) {
196-
if (__DEV__) console.log('Legal update error:', err2.errors?.[0]?.message);
220+
} as ClerkUpdateParams);
221+
} catch (err2: unknown) {
222+
if (__DEV__) {
223+
const error = err2 as { errors?: Array<{ message?: string }> };
224+
console.log('Legal update error:', error.errors?.[0]?.message);
225+
}
197226
}
198227
}
199228

@@ -217,14 +246,15 @@ export default function AuthScreen() {
217246
});
218247
showToast('Unable to complete sign up. Check Clerk Dashboard settings.');
219248
}
220-
} catch (err: any) {
249+
} catch (err: unknown) {
250+
const error = err as ClerkError;
221251
logger.error('Email verification failed', err, {
222252
attributes: {
223253
email,
224-
errorMessage: err.errors?.[0]?.message,
254+
errorMessage: error.errors?.[0]?.message,
225255
},
226256
});
227-
showToast(err.errors?.[0]?.message || 'Invalid code');
257+
showToast(error.errors?.[0]?.message || 'Invalid code');
228258
} finally {
229259
setLoading(false);
230260
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import { useApiService, type Folder } from '../services/api';
1010
import { FOLDER_CARD, ACTION_BUTTON, FOLDER_COLORS } from '../constants/ui';
1111
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput } from '@gorhom/bottom-sheet';
1212

13-
interface Props {
14-
navigation?: any;
15-
}
16-
1713
// Special views configuration matching web app
1814
const SPECIAL_VIEWS = [
1915
{
@@ -46,7 +42,7 @@ function getTimeOfDay(): string {
4642
return 'evening';
4743
}
4844

49-
export default function FoldersScreen({ navigation }: Props) {
45+
export default function FoldersScreen() {
5046
const theme = useTheme();
5147
const api = useApiService();
5248
const router = useRouter();

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@ import { Ionicons } from '@expo/vector-icons';
99
import { NOTE_CARD, FOLDER_CARD, SECTION, FOLDER_COLORS } from '../constants/ui';
1010
import { BottomSheetModal, BottomSheetView, BottomSheetBackdrop, BottomSheetTextInput } from '@gorhom/bottom-sheet';
1111

12+
interface RouteParams {
13+
folderId?: string;
14+
viewType?: 'all' | 'starred' | 'archived' | 'trash';
15+
searchQuery?: string;
16+
folderName?: string;
17+
}
18+
1219
interface Props {
13-
navigation?: any;
14-
route?: any;
20+
navigation?: {
21+
navigate: (screen: string, params?: Record<string, unknown>) => void;
22+
};
23+
route?: {
24+
params?: RouteParams;
25+
};
1526
renderHeader?: () => React.ReactNode;
1627
scrollY?: Animated.Value;
1728
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import { UsageBottomSheet } from '../components/settings/UsageBottomSheet';
1616

1717
interface Props {
1818
onLogout?: () => void;
19-
navigation?: any;
2019
}
2120

22-
export default function SettingsScreen({ onLogout, navigation }: Props) {
21+
export default function SettingsScreen({ onLogout }: Props) {
2322
const theme = useTheme();
2423
const { user } = useUser();
2524
const router = useRouter();

0 commit comments

Comments
 (0)