Skip to content

types: createServerFn does not accept branded strings #3157

Open
@ben-pr-p

Description

Which project does this relate to?

Start

Describe the bug

Code:

export const listWidgets = createServerFn({ method: "GET" }).handler(
  async () => {
    return [
      {
        id: "1" as string & {
          __brand: "id";
        },
        name: "Widget 1",
      },
    ];
  }
);

Type error:
Image

 Type '() => string' is not assignable to type '"Function is not serializable"'

Is the type error.

Steps to Reproduce the Bug or Issue

Code above.

Expected behavior

It should allow branded strings - commonly used for database IDs, etc.

Screenshots or Videos

No response

Platform

    "@tanstack/react-router": "^1.95.5",
    "@tanstack/start": "^1.95.5",

Additional context

No response

Metadata

Assignees

No one assigned

    Labels

    typesChanges to the typescript types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions