Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/nice-moons-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
3 changes: 2 additions & 1 deletion packages/clerk-js/src/core/resources/SignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ class SignInFuture implements SignInFutureResource {
constructor(readonly resource: SignIn) {}

get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'needs_identifier';
}
Comment on lines 610 to 613
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add explicit return type and use nullish coalescing for correctness.

  • Public API: annotate getter return type per guidelines.
  • Prefer ?? over || to avoid unintended fallback on falsy strings (defensive).

Apply:

-  get status() {
-    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
-    return this.resource.status || 'needs_identifier';
-  }
+  get status(): SignInStatus {
+    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
+    return this.resource.status ?? 'needs_identifier';
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'needs_identifier';
}
get status(): SignInStatus {
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status ?? 'needs_identifier';
}
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignIn.ts around lines 562 to 565, the
getter lacks an explicit return type and uses || which can incorrectly fall back
on falsy but valid strings; update the getter signature to include an explicit
return type (e.g., get status(): string or the precise union type used by the
public API) and replace the || fallback with the nullish coalescing operator,
returning this.resource.status ?? 'needs_identifier', ensuring the annotated
return type matches the actual allowed status values.


get availableStrategies() {
Expand Down
3 changes: 2 additions & 1 deletion packages/clerk-js/src/core/resources/SignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ class SignUpFuture implements SignUpFutureResource {
constructor(readonly resource: SignUp) {}

get status() {
return this.resource.status;
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy
return this.resource.status || 'missing_requirements';
}
Comment on lines 553 to 556
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Annotate getter return type and use ?? for the fallback.

  • Add explicit return type to the public getter.
  • Use nullish coalescing for robustness.

Apply:

-  get status() {
-    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
-    return this.resource.status || 'missing_requirements';
-  }
+  get status(): SignUpStatus {
+    // @TODO hooks-revamp: Consolidate this fallback val with stateProxy
+    return this.resource.status ?? 'missing_requirements';
+  }
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignUp.ts around lines 542 to 545, the
public getter lacks an explicit return type and uses || for fallback; change the
signature to include an explicit return type (e.g., string or the appropriate
union type used elsewhere) and replace the logical OR with nullish coalescing so
the getter returns this.resource.status ?? 'missing_requirements'.


get unverifiedFields() {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/signInFuture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface SignInFutureResource {
* The status of the current sign-in attempt as a string (for example, `'needs_identifier'`, `'needs_first_factor'`,
* `'complete'`, etc.)
*/
readonly status: SignInStatus | null;
readonly status: SignInStatus;

/**
* Indicates that there is not a matching user for the first-factor verification used, and that the sign-in can be
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/signUpFuture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface SignUpFutureResource {
/**
* The status of the current sign-up attempt as a string (for example, `'missing_requirements'`, `'complete'`, `'abandoned'`, etc.)
*/
readonly status: SignUpStatus | null;
readonly status: SignUpStatus;

/**
* An array of strings representing unverified fields such as `’email_address’`. Can be used to detect when verification is necessary.
Expand Down
Loading