Skip to content

issue: Branded Type in FormValues is incorrectly expanded in defaultValues #13221

@tsutoringo

Description

@tsutoringo

Version Number

7.66.1

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/spring-http-ydmrzj

Steps to reproduce

  1. Define a Branded Type by intersecting a primitive (e.g., string) with a brand object.
  2. Use this type in a FormValues interface.
  3. Pass a value of an incorrect primitive type (e.g., number) to defaultValues for that field.
  4. Observe the TypeScript error message. Instead of a simple "type mismatch" between string and number, the error indicates that the value is being compared against the internal brand structure (an object), showing that react-hook-form has incorrectly expanded the Branded Type.
Image

Expected behaviour

When a type is an intersection of a primitive and a brand (e.g., string & { ... }), it should not be expanded into an object structure. The expected behavior is that defaultValues should validate the value against the BrandedType itself, maintaining the type's integrity as a single field value rather than a nested form object.

What browsers are you seeing the problem on?

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions