-
Notifications
You must be signed in to change notification settings - Fork 382
fix(clerk-js,type): Remove null
from SignIn/SignUp future class `.s…
#6746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughStatus handling was revised to remove nulls and provide explicit fallback strings. SignInFuture and SignUpFuture getters now return concrete statuses when underlying values are falsy. Corresponding type interfaces were updated to make status non-nullable. Changes
Sequence Diagram(s)sequenceDiagram
actor Caller
participant SignInFuture
participant Resource as SignIn Resource
Caller->>SignInFuture: get status()
SignInFuture->>Resource: read status
alt Resource has status
SignInFuture-->>Caller: SignInStatus
else status is falsy
Note over SignInFuture: Fallback applied
SignInFuture-->>Caller: "needs_identifier"
end
sequenceDiagram
actor Caller
participant SignUpFuture
participant Resource as SignUp Resource
Caller->>SignUpFuture: get status()
SignUpFuture->>Resource: read status
alt Resource has status
SignUpFuture-->>Caller: SignUpStatus
else status is falsy
Note over SignUpFuture: Fallback applied
SignUpFuture-->>Caller: "missing_requirements"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
✨ Finishing Touches
🧪 Generate unit tests
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/types/src/signInFuture.ts (1)
98-98
: Non-nullablestatus
is a TS-facing breaking change; tighten docs.
- This removes
null
from the public type, which can break downstream TS consumers relying onnull
checks. Ensure a release note/semver label reflects this.- Clarify in JSDoc that
status
is nevernull
.Proposed JSDoc tweak:
- * `'complete'`, etc.) + * `'complete'`, etc.). This property is never `null`.packages/types/src/signUpFuture.ts (1)
53-53
: Make the non-null contract explicit; note potential type break.
- Same as SignIn: this is a breaking type-only change; flag in release notes.
- Update JSDoc to state it’s never
null
.Proposed JSDoc tweak:
- * An array of strings representing unverified fields such as `’email_address’`. Can be used to detect when verification is necessary. + * The status is never `null`. Example values: `'missing_requirements'`, `'complete'`, `'abandoned'`.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
packages/clerk-js/src/core/resources/SignIn.ts
(1 hunks)packages/clerk-js/src/core/resources/SignUp.ts
(1 hunks)packages/types/src/signInFuture.ts
(1 hunks)packages/types/src/signUpFuture.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/types/src/signInFuture.ts
packages/types/src/signUpFuture.ts
packages/clerk-js/src/core/resources/SignIn.ts
packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code graph analysis (2)
packages/types/src/signInFuture.ts (1)
packages/types/src/signInCommon.ts (1)
SignInStatus
(61-66)
packages/types/src/signUpFuture.ts (1)
packages/types/src/signUpCommon.ts (1)
SignUpStatus
(25-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
get status() { | ||
return this.resource.status; | ||
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy | ||
return this.resource.status || 'needs_identifier'; | ||
} |
There was a problem hiding this comment.
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.
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 status() { | ||
return this.resource.status; | ||
// @TODO hooks-revamp: Consolidate this fallback val with stateProxy | ||
return this.resource.status || 'missing_requirements'; | ||
} |
There was a problem hiding this comment.
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'.
Description
Fixes the state during the
stateProxy
->clerk-js loaded
transition (default value -> null -> fapi value)This is a temporary fix as ideally, we'd like to consolidate the default values of
clerk-js
with the default values ofstateProxy
found inclerk-react
which will happen in an upcoming PRChecklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit