Skip to content

Commit a9c13ca

Browse files
authored
fix(shared): Update method return types (#7250)
1 parent 5966383 commit a9c13ca

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

.changeset/orange-grapes-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
[Experimental] Fix method return types for new custom flow APIs.

packages/shared/src/types/signInFuture.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ClerkError } from '../errors/clerkError';
12
import type { SetActiveNavigate } from './clerk';
23
import type { PhoneCodeChannel } from './phoneCodeChannel';
34
import type { SignInFirstFactor, SignInSecondFactor, SignInStatus, UserData } from './signInCommon';
@@ -340,12 +341,12 @@ export interface SignInFutureResource {
340341
* > Once the sign-in process is complete, call the `signIn.finalize()` method to set the newly created session as
341342
* > the active session.
342343
*/
343-
create: (params: SignInFutureCreateParams) => Promise<{ error: unknown }>;
344+
create: (params: SignInFutureCreateParams) => Promise<{ error: ClerkError | null }>;
344345

345346
/**
346347
* Used to submit a password to sign-in.
347348
*/
348-
password: (params: SignInFuturePasswordParams) => Promise<{ error: unknown }>;
349+
password: (params: SignInFuturePasswordParams) => Promise<{ error: ClerkError | null }>;
349350

350351
/**
351352
*
@@ -354,12 +355,12 @@ export interface SignInFutureResource {
354355
/**
355356
* Used to send an email code to sign-in
356357
*/
357-
sendCode: (params: SignInFutureEmailCodeSendParams) => Promise<{ error: unknown }>;
358+
sendCode: (params: SignInFutureEmailCodeSendParams) => Promise<{ error: ClerkError | null }>;
358359

359360
/**
360361
* Used to verify a code sent via email to sign-in
361362
*/
362-
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
363+
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
363364
};
364365

365366
/**
@@ -369,12 +370,12 @@ export interface SignInFutureResource {
369370
/**
370371
* Used to send an email link to sign-in
371372
*/
372-
sendLink: (params: SignInFutureEmailLinkSendParams) => Promise<{ error: unknown }>;
373+
sendLink: (params: SignInFutureEmailLinkSendParams) => Promise<{ error: ClerkError | null }>;
373374

374375
/**
375376
* Will wait for verification to complete or expire
376377
*/
377-
waitForVerification: () => Promise<{ error: unknown }>;
378+
waitForVerification: () => Promise<{ error: ClerkError | null }>;
378379

379380
/**
380381
* The verification status
@@ -404,12 +405,12 @@ export interface SignInFutureResource {
404405
/**
405406
* Used to send a phone code to sign-in
406407
*/
407-
sendCode: (params: SignInFuturePhoneCodeSendParams) => Promise<{ error: unknown }>;
408+
sendCode: (params: SignInFuturePhoneCodeSendParams) => Promise<{ error: ClerkError | null }>;
408409

409410
/**
410411
* Used to verify a code sent via phone to sign-in
411412
*/
412-
verifyCode: (params: SignInFuturePhoneCodeVerifyParams) => Promise<{ error: unknown }>;
413+
verifyCode: (params: SignInFuturePhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
413414
};
414415

415416
/**
@@ -419,23 +420,23 @@ export interface SignInFutureResource {
419420
/**
420421
* Used to send a password reset code to the first email address on the account
421422
*/
422-
sendCode: () => Promise<{ error: unknown }>;
423+
sendCode: () => Promise<{ error: ClerkError | null }>;
423424

424425
/**
425426
* Used to verify a password reset code sent via email. Will cause `signIn.status` to become `'needs_new_password'`.
426427
*/
427-
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
428+
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
428429

429430
/**
430431
* Used to submit a new password, and move the `signIn.status` to `'complete'`.
431432
*/
432-
submitPassword: (params: SignInFutureResetPasswordSubmitParams) => Promise<{ error: unknown }>;
433+
submitPassword: (params: SignInFutureResetPasswordSubmitParams) => Promise<{ error: ClerkError | null }>;
433434
};
434435

435436
/**
436437
* Used to perform OAuth authentication.
437438
*/
438-
sso: (params: SignInFutureSSOParams) => Promise<{ error: unknown }>;
439+
sso: (params: SignInFutureSSOParams) => Promise<{ error: ClerkError | null }>;
439440

440441
/**
441442
*
@@ -444,45 +445,45 @@ export interface SignInFutureResource {
444445
/**
445446
* Used to send a phone code as a second factor to sign-in
446447
*/
447-
sendPhoneCode: () => Promise<{ error: unknown }>;
448+
sendPhoneCode: () => Promise<{ error: ClerkError | null }>;
448449

449450
/**
450451
* Used to verify a phone code sent as a second factor to sign-in
451452
*/
452-
verifyPhoneCode: (params: SignInFutureMFAPhoneCodeVerifyParams) => Promise<{ error: unknown }>;
453+
verifyPhoneCode: (params: SignInFutureMFAPhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
453454

454455
/**
455456
* Used to verify a TOTP code as a second factor to sign-in
456457
*/
457-
verifyTOTP: (params: SignInFutureTOTPVerifyParams) => Promise<{ error: unknown }>;
458+
verifyTOTP: (params: SignInFutureTOTPVerifyParams) => Promise<{ error: ClerkError | null }>;
458459

459460
/**
460461
* Used to verify a backup code as a second factor to sign-in
461462
*/
462-
verifyBackupCode: (params: SignInFutureBackupCodeVerifyParams) => Promise<{ error: unknown }>;
463+
verifyBackupCode: (params: SignInFutureBackupCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
463464
};
464465

465466
/**
466467
* Used to perform a ticket-based sign-in.
467468
*/
468-
ticket: (params?: SignInFutureTicketParams) => Promise<{ error: unknown }>;
469+
ticket: (params?: SignInFutureTicketParams) => Promise<{ error: ClerkError | null }>;
469470

470471
/**
471472
* Used to perform a Web3-based sign-in.
472473
*/
473-
web3: (params: SignInFutureWeb3Params) => Promise<{ error: unknown }>;
474+
web3: (params: SignInFutureWeb3Params) => Promise<{ error: ClerkError | null }>;
474475

475476
/**
476477
* Initiates a passkey-based authentication flow, enabling users to authenticate using a previously
477478
* registered passkey. When called without parameters, this method requires a prior call to
478479
* `SignIn.create({ strategy: 'passkey' })` to initialize the sign-in context. This pattern is particularly useful in
479480
* scenarios where the authentication strategy needs to be determined dynamically at runtime.
480481
*/
481-
passkey: (params?: SignInFuturePasskeyParams) => Promise<{ error: unknown }>;
482+
passkey: (params?: SignInFuturePasskeyParams) => Promise<{ error: ClerkError | null }>;
482483

483484
/**
484485
* Used to convert a sign-in with `status === 'complete'` into an active session. Will cause anything observing the
485486
* session state (such as the `useUser()` hook) to update automatically.
486487
*/
487-
finalize: (params?: SignInFutureFinalizeParams) => Promise<{ error: unknown }>;
488+
finalize: (params?: SignInFutureFinalizeParams) => Promise<{ error: ClerkError | null }>;
488489
}

packages/shared/src/types/signUpFuture.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ClerkError } from '../errors/clerkError';
12
import type { SetActiveNavigate } from './clerk';
23
import type { PhoneCodeChannel } from './phoneCodeChannel';
34
import type { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUpCommon';
@@ -398,12 +399,12 @@ export interface SignUpFutureResource {
398399
* > Once the sign-up process is complete, call the `signUp.finalize()` method to set the newly created session as
399400
* > the active session.
400401
*/
401-
create: (params: SignUpFutureCreateParams) => Promise<{ error: unknown }>;
402+
create: (params: SignUpFutureCreateParams) => Promise<{ error: ClerkError | null }>;
402403

403404
/**
404405
* Updates the current `SignUp`.
405406
*/
406-
update: (params: SignUpFutureUpdateParams) => Promise<{ error: unknown }>;
407+
update: (params: SignUpFutureUpdateParams) => Promise<{ error: ClerkError | null }>;
407408

408409
/**
409410
*
@@ -412,47 +413,47 @@ export interface SignUpFutureResource {
412413
/**
413414
* Used to send an email code to verify an email address.
414415
*/
415-
sendEmailCode: () => Promise<{ error: unknown }>;
416+
sendEmailCode: () => Promise<{ error: ClerkError | null }>;
416417

417418
/**
418419
* Used to verify a code sent via email.
419420
*/
420-
verifyEmailCode: (params: SignUpFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
421+
verifyEmailCode: (params: SignUpFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
421422

422423
/**
423424
* Used to send a phone code to verify a phone number.
424425
*/
425-
sendPhoneCode: (params: SignUpFuturePhoneCodeSendParams) => Promise<{ error: unknown }>;
426+
sendPhoneCode: (params: SignUpFuturePhoneCodeSendParams) => Promise<{ error: ClerkError | null }>;
426427

427428
/**
428429
* Used to verify a code sent via phone.
429430
*/
430-
verifyPhoneCode: (params: SignUpFuturePhoneCodeVerifyParams) => Promise<{ error: unknown }>;
431+
verifyPhoneCode: (params: SignUpFuturePhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
431432
};
432433

433434
/**
434435
* Used to sign up using an email address and password.
435436
*/
436-
password: (params: SignUpFuturePasswordParams) => Promise<{ error: unknown }>;
437+
password: (params: SignUpFuturePasswordParams) => Promise<{ error: ClerkError | null }>;
437438

438439
/**
439440
* Used to create an account using an OAuth connection.
440441
*/
441-
sso: (params: SignUpFutureSSOParams) => Promise<{ error: unknown }>;
442+
sso: (params: SignUpFutureSSOParams) => Promise<{ error: ClerkError | null }>;
442443

443444
/**
444445
* Used to perform a ticket-based sign-up.
445446
*/
446-
ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
447+
ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: ClerkError | null }>;
447448

448449
/**
449450
* Used to perform a Web3-based sign-up.
450451
*/
451-
web3: (params: SignUpFutureWeb3Params) => Promise<{ error: unknown }>;
452+
web3: (params: SignUpFutureWeb3Params) => Promise<{ error: ClerkError | null }>;
452453

453454
/**
454455
* Used to convert a sign-up with `status === 'complete'` into an active session. Will cause anything observing the
455456
* session state (such as the `useUser()` hook) to update automatically.
456457
*/
457-
finalize: (params?: SignUpFutureFinalizeParams) => Promise<{ error: unknown }>;
458+
finalize: (params?: SignUpFutureFinalizeParams) => Promise<{ error: ClerkError | null }>;
458459
}

0 commit comments

Comments
 (0)