Skip to content

[react-form-start] TanStack Start serverValidate types don't match Next.js types #2239

Description

@sprucepad

Describe the bug

@tanstack/react-form-start's types for serverValidate don't match @tanstack/react-form-nextjs. Runtime behavior isn't affected (both parse rememberMe as a boolean).

In Start:

import { createServerValidate as createStartServerValidate } from "@tanstack/react-form-start";

const startServerValidate = createStartServerValidate({
    onServerValidate: Validator,
});

await startServerValidate(new FormData(), {
    booleans: ["rememberMe"], // Error
    // ^ Object literal may only specify known properties, and 'booleans' does not exist in type 'FormDataTransform'., a
});

In Next.js:

import { createServerValidate as createNextServerValidate } from "@tanstack/react-form-nextjs";

const nextServerValidate = createNextServerValidate({
    onServerValidate: Validator
});

await nextServerValidate(new FormData(), {
    booleans: ["rememberMe"], // No error!
});

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgLzgXzgMyhEcBEyEAJvgNwBQFAxhAHYDO8AagIYA2wxrM0cAvCgB0EAEYArAKbUYACgQU4SuFEkg1oyVACykgFzDRECO0ms6sgJQAaCmkuUKoSLERxqqnpIDKWgG5abJzcMJJwrAzunqHeMKywvlABUEFcXuhYOHj4AAJxjHHUANYA9J4yALSY0CAVTPEw5FS0BXD1Cf6BHGmhAlFmMXEdSV3BXvKKyvSJyakh+nBzPNC29o6sAO6swPDtMDOjPZKydJIbcABiNQAiPKxW1oiTSkYmZowGANr4quogmjpJPgALqPEolOAAUSgOCgzzg4LgAD04AB5CTSeCcUJQDhwECsACecHo7GJDDA0mAmGJRToEA2dDgYBwlNgwEkDEe5mIcAA5K9TOYGHy4MQIJy4PT4JIAB7AJhwYBMmCEyn8q5QEC3OIAFVxjGqWr5QjsDiozmg8CQHgGPk6KW683CkVtXgAcnL9g6lr0MNhcAQ8sLCqVyjAqjUKqdZTBxAwmjR6IqY96Ro6xr1BG7Qp7YwcM0cJsoSXQC76Fr7oGb1lsdlKveWneNTudNdq7g8niXBe8GF8fmoNFpdCCwRD3RA4FpYQBCeGIpEAfhrVFV6rzMAACvFWHhBDvceocQwADzryQQTAN-M+5uhAB8nwAjMDKIilMuKBe4LEGoe9z6ADjy0M8LyvNohjTWZ70kJ9X3fCFPxXIA

Steps to reproduce

  1. Install @tanstack/react-form-start and @tanstack/react-form-nextjs and a validator (Zod in the example, or use the TypeScript playground)
  2. Create a server validate using the same validator in both
  3. Call the validate, passing blank FormData and an object containing booleans (or any other key) for both
  4. See the error in Start, but not in Next

Expected behavior

Both should either include { booleans, dates, arrays, files, numbers } as string[]s like in the Next adapter, or not include them.

How often does this bug happen?

Every time

Screenshots or Videos

Image

Platform

  • OS: Linux
  • Browser: Zen Browser (Firefox)
  • Browser version: 1.21.6b (Firefox 152.0.5)

TanStack Form adapter

react-form

TanStack Form version

1.33.1

TypeScript version

6.0.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions