@@ -21,6 +21,30 @@ import { Input } from '../components/ui/Input';
2121import { Ionicons } from '@expo/vector-icons' ;
2222import { 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 }
0 commit comments