Skip to content
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

types: createServerFn does not accept branded strings #3157

Open
ben-pr-p opened this issue Jan 13, 2025 · 1 comment · May be fixed by #3849
Open

types: createServerFn does not accept branded strings #3157

ben-pr-p opened this issue Jan 13, 2025 · 1 comment · May be fixed by #3849
Labels
types Changes to the typescript types

Comments

@ben-pr-p
Copy link

ben-pr-p commented Jan 13, 2025

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

@schiller-manuel schiller-manuel added the types Changes to the typescript types label Jan 13, 2025
@Aleksion
Copy link
Contributor

This is super annoying. I use branded types for all my id's so this breaks typing for all my server functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Changes to the typescript types
Projects
None yet
3 participants