Skip to content

Conversation

@dstaley
Copy link
Member

@dstaley dstaley commented Nov 10, 2025

Description

This PR updates the fields type on Errors to be specific to either sign-in or sign-up. It also adds a basic test for the errorsToParsedErrors function.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features
    • Enhanced error handling with distinct, flow-specific field types for sign-in and sign-up to provide clearer, more accurate error feedback.
  • Refactor
    • Reworked internal error shape to a generic per-flow structure, improving consistency of error data across flows.
  • Tests
    • Added unit tests covering various error scenarios to ensure correct parsing and mapping of API and non-API errors.

@changeset-bot
Copy link

changeset-bot bot commented Nov 10, 2025

🦋 Changeset detected

Latest commit: 8b52a19

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/shared Minor
@clerk/clerk-react Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/types Patch
@clerk/vue Patch
@clerk/localizations Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 10, 2025 5:01pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Introduces flow-specific error types and parsing: a generic errorsToParsedErrors now accepts initial field shapes and is wrapped by errorsToSignInErrors / errorsToSignUpErrors; state defaults and shared types were updated to enforce sign-in vs sign-up field structures.

Changes

Cohort / File(s) Summary
Changeset Documentation
​.changeset/clear-flowers-guess.md
Adds changeset documenting minor version bumps for @clerk/clerk-js, @clerk/shared, and @clerk/clerk-react and notes experimental change to per-flow error field types.
Shared Types
packages/shared/src/types/state.ts
Introduces generic Errors<T>, defines SignInFields and SignUpFields, and adds SignInErrors / SignUpErrors aliases. Updates SignInSignalValue.errors and SignUpSignalValue.errors to use the new types.
Error Parsing / Signals
packages/clerk-js/src/core/signals.ts
Refactors error parsing: exposes generic errorsToParsedErrors<T>(error, initialFields), adds errorsToSignInErrors() and errorsToSignUpErrors() wrappers, adds guards to avoid assigning unknown field keys, and updates sign-in/sign-up computed signals to use the new helpers.
React State Proxy Defaults
packages/react/src/stateProxy.ts
Replaces single defaultErrors() with defaultSignInErrors() and defaultSignUpErrors() factories; updates imports and proxies to use the appropriate default error shapes per flow.
Tests
packages/clerk-js/src/core/__tests__/signals.test.ts
Adds tests for errorsToParsedErrors behavior covering null errors, non-API errors, API field errors mapping, and API errors without field entries.

Sequence Diagram(s)

sequenceDiagram
  participant API as API
  participant Parser as errorsToParsedErrors<T>
  participant Wrapper as errorsToSignIn/SignUpErrors
  participant Signal as signIn/signUp Signal
  participant Proxy as StateProxy

  API->>Wrapper: returns error payload
  Wrapper->>Parser: call with (error, initialFields)
  Parser-->>Wrapper: Errors<T> { fields, raw, global }
  Wrapper-->>Signal: mapped SignInErrors/SignUpErrors
  Signal-->>Proxy: updated signal value (errors property)
  Note right of Parser `#D6EAF8`: Parser guards against unknown fields\nand preserves initial shape
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Pay special attention to type propagation across packages (packages/sharedclerk-jsreact).
  • Review errorsToParsedErrors signature change (public/generic) and its call sites.
  • Verify guard logic preventing assignment to unknown fields and ensure tests cover edge cases.

Poem

🐰 I hopped through types and parsed each string,
I nudged fields home so errors sing,
Sign-in and sign-up know their name,
No stray keys will cause them shame,
🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making error fields operation-specific (sign-in vs sign-up) across three packages.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ds.fix/signals-form-types

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 10, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7195

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7195

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7195

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7195

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7195

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7195

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7195

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7195

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7195

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7195

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7195

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7195

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7195

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7195

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7195

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7195

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7195

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7195

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7195

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7195

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7195

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7195

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7195

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7195

commit: 8b52a19

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/shared/src/types/state.ts (1)

63-100: Don't drop sign-up field errors for web3Wallet/unsafeMetadata.

errorsToParsedErrors only assigns parsed field errors when the key already exists on fields. Because SignUpFields omits web3Wallet and unsafeMetadata—both exposed on the sign-up resource—any API validation error targeting web3_wallet or unsafe_metadata now gets silently discarded. That breaks downstream UIs that rely on those errors (e.g., custom metadata validation). Please add these fields here, and mirror them in the default/error factories so the parser can surface those errors again.

Apply this diff (and keep the same additions in the other call sites):

 export interface SignUpFields {
@@
   captcha: FieldError | null;
   /**
    * The error for the legal accepted field.
    */
   legalAccepted: FieldError | null;
+  /**
+   * The error for the web3 wallet field.
+   */
+  web3Wallet: FieldError | null;
+  /**
+   * The error for the unsafe metadata field.
+   */
+  unsafeMetadata: FieldError | null;
 }
packages/react/src/stateProxy.ts (1)

17-31: Keep default sign-up errors in sync with the type.

After adding web3Wallet and unsafeMetadata to SignUpFields, the default constructor should seed those slots so consumers never see undefined and parsed errors can land.

Add the missing fields:

 const defaultSignUpErrors = (): SignUpErrors => ({
   fields: {
     firstName: null,
     lastName: null,
     emailAddress: null,
     phoneNumber: null,
     password: null,
     username: null,
     code: null,
     captcha: null,
     legalAccepted: null,
+    web3Wallet: null,
+    unsafeMetadata: null,
   },
   raw: null,
   global: null,
 });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 67b98a9 and 3b8c675.

📒 Files selected for processing (4)
  • .changeset/clear-flowers-guess.md (1 hunks)
  • packages/clerk-js/src/core/signals.ts (6 hunks)
  • packages/react/src/stateProxy.ts (3 hunks)
  • packages/shared/src/types/state.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/clear-flowers-guess.md
**/*.{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/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.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/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.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/react/src/stateProxy.ts
  • packages/shared/src/types/state.ts
  • packages/clerk-js/src/core/signals.ts
🧬 Code graph analysis (3)
packages/react/src/stateProxy.ts (1)
packages/shared/src/types/state.ts (2)
  • SignInErrors (105-105)
  • SignUpErrors (110-110)
packages/shared/src/types/state.ts (1)
packages/shared/src/errors/globalHookError.ts (1)
  • ClerkGlobalHookError (23-23)
packages/clerk-js/src/core/signals.ts (1)
packages/shared/src/types/state.ts (3)
  • Errors (26-40)
  • SignInErrors (105-105)
  • SignUpErrors (110-110)
⏰ 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). (4)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/clear-flowers-guess.md (1)

1-7: Changelog entry looks good.

Release note and version bumps match the scoped change.

Comment on lines +97 to +108
function errorsToSignUpErrors(error: ClerkError | null): SignUpErrors {
return errorsToParsedErrors(error, {
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null,
password: null,
username: null,
code: null,
captcha: null,
legalAccepted: null,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Initialize all sign-up fields before parsing errors.

Once we add web3Wallet and unsafeMetadata to SignUpFields, we also need to seed them here. Otherwise the name in parsedErrors.fields guard still filters those errors out at runtime.

Please extend the initializer accordingly:

 function errorsToSignUpErrors(error: ClerkError | null): SignUpErrors {
   return errorsToParsedErrors(error, {
     firstName: null,
     lastName: null,
     emailAddress: null,
     phoneNumber: null,
     password: null,
     username: null,
     code: null,
     captcha: null,
     legalAccepted: null,
+    web3Wallet: null,
+    unsafeMetadata: null,
   });
 }
📝 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
function errorsToSignUpErrors(error: ClerkError | null): SignUpErrors {
return errorsToParsedErrors(error, {
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null,
password: null,
username: null,
code: null,
captcha: null,
legalAccepted: null,
});
function errorsToSignUpErrors(error: ClerkError | null): SignUpErrors {
return errorsToParsedErrors(error, {
firstName: null,
lastName: null,
emailAddress: null,
phoneNumber: null,
password: null,
username: null,
code: null,
captcha: null,
legalAccepted: null,
web3Wallet: null,
unsafeMetadata: null,
});
}
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/signals.ts around lines 97 to 108, the initializer
object passed to errorsToParsedErrors is missing the new SignUpFields keys
web3Wallet and unsafeMetadata, so those errors get filtered out at runtime;
update the initializer to include web3Wallet: null and unsafeMetadata: null
alongside the existing fields so all sign-up fields are seeded before parsing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/clerk-js/src/core/signals.ts (1)

97-109: Initialize all sign-up fields before parsing errors.

Once we add web3Wallet and unsafeMetadata to SignUpFields, we also need to seed them here. Otherwise the name in parsedErrors.fields guard still filters those errors out at runtime.

Please extend the initializer accordingly:

 function errorsToSignUpErrors(error: ClerkError | null): SignUpErrors {
   return errorsToParsedErrors(error, {
     firstName: null,
     lastName: null,
     emailAddress: null,
     phoneNumber: null,
     password: null,
     username: null,
     code: null,
     captcha: null,
     legalAccepted: null,
+    web3Wallet: null,
+    unsafeMetadata: null,
   });
 }

Based on past review comments.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3b8c675 and 8b52a19.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/__tests__/signals.test.ts (1 hunks)
  • packages/clerk-js/src/core/signals.ts (6 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/src/core/tests/signals.test.ts
🧰 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/clerk-js/src/core/signals.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/clerk-js/src/core/signals.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/signals.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/signals.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
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly 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
Use const assertions for literal types: as const
Use satisfies 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 ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly 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/clerk-js/src/core/signals.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/clerk-js/src/core/signals.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/signals.ts (1)
packages/shared/src/types/state.ts (3)
  • Errors (26-40)
  • SignInErrors (105-105)
  • SignUpErrors (110-110)
⏰ 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: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/clerk-js/src/core/signals.ts (4)

2-2: LGTM!

The import statement correctly includes the new flow-specific error types SignInErrors and SignUpErrors.


13-21: LGTM!

The sign-in computed signal correctly uses the new errorsToSignInErrors helper, properly integrating flow-specific error handling.


27-35: LGTM!

The sign-up computed signal correctly uses the new errorsToSignUpErrors helper, properly integrating flow-specific error handling.


89-95: No issues found.

All fields from the SignInFields interface are properly initialized. The errorsToSignInErrors function correctly initializes all three fields—identifier, password, and code—with null values, matching the interface definition.

Comment on lines +71 to +73
if (name in parsedErrors.fields) {
(parsedErrors.fields as any)[name] = error;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Replace any with a type-safe assignment.

The use of any type casting violates the project's TypeScript guidelines, which require avoiding any types. While the guard at line 71 ensures the field exists, the type system isn't aware of this refinement.

Consider this type-safe alternative:

         const name = snakeToCamel(error.meta.paramName);
         if (name in parsedErrors.fields) {
-          (parsedErrors.fields as any)[name] = error;
+          parsedErrors.fields = {
+            ...parsedErrors.fields,
+            [name]: error,
+          } as T;
         }

Or use a more explicit approach with a helper function that preserves type safety:

function setField<T extends Record<string, unknown>>(fields: T, key: string, value: unknown): T {
  if (key in fields) {
    return { ...fields, [key]: value } as T;
  }
  return fields;
}
🤖 Prompt for AI Agents
In packages/clerk-js/src/core/signals.ts around lines 71 to 73, the code uses an
unsafe (parsedErrors.fields as any)[name] assignment; replace this with a
type-safe update so we avoid any casts. Use a typed index signature or a small
generic helper: narrow parsedErrors.fields to the appropriate Record<string,
unknown> (or the exact field type) before assigning, or call a helper like
setField<T extends Record<string, unknown>>(fields, key, value) that returns a
new fields object with the updated key typed as T; ensure the helper or
narrowing preserves the original fields type and returns the updated object back
into parsedErrors.fields without using any.

@dstaley dstaley merged commit a1d10fc into main Nov 12, 2025
44 checks passed
@dstaley dstaley deleted the ds.fix/signals-form-types branch November 12, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants