tanstack-start: generated JSON fields typed as unknown (`_transforms`, session `metadata`) break createServerFn's serialisable return check in 4.0.0-beta.10

オープン
#19,783 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@r1tsuu がすでに取り組んでいます。

2026年11月20日 から。

  • #19784 @AdityaxDeore による — オープン

評価

この issue はまだ評価されていません。

説明

area: core Bug framework: tanstack-start Payload OSS
Describe the Bug

On 4.0.0-beta.10 with @payloadcms/tanstack-start, returning a Payload document from a TanStack Start server function no longer type-checks in TanStack's default strict mode.

Two fields new in the generated types are typed as JSON unknown, which TanStack's serialisability check rejects (TanStack maintainers consider this intended: https://github.com/TanStack/router/issues/5229):

  • _transforms on every upload collection (UploadTransforms.encoding: { [k: string]: unknown })
  • sessions[].metadata on auth collections ({ [k: string]: unknown } | unknown[] | ...), which reaches every document through the createdBy / updatedBy relationships to the user

So any server function returning a document with an upload field, or any document with createdBy/updatedBy, fails to compile. It compiled on 4.0.0-beta.6.

Link to the code that reproduces this issue

Minimal repro inside any @payloadcms/tanstack-start project with an upload collection media and an auth collection users:

import { createServerFn } from '@tanstack/react-start'
import { getPayload } from 'payload'
import config from '@payload-config'

export const getMedia = createServerFn({ method: 'GET' }).handler(async () => {
  const payload = await getPayload({ config })
  return payload.findByID({ collection: 'media', id: 1 })
})
Reproduction Steps
  1. Create a TanStack Start project on 4.0.0-beta.10 with an upload collection.
  2. Run payload generate:types.
  3. Add the server function above and run tsc --noEmit.

Error (abridged):

Argument of type '() => Promise<Media>' is not assignable to parameter of type 'ServerFn<Register, "GET", undefined, undefined, Promise<Media>, true>'.
  ...
    Types of property '_transforms' are incompatible.
      ...
        Types of property 'encoding' are incompatible.
          Type 'unknown' is not assignable to type 'SerializationError<"Type may not be serializable">'.

The same happens through createdBy → User → sessions → metadata.

Current workarounds are createServerFn({ strict: { output: false } }), which TanStack's docs discourage, or mapping documents to narrower types by hand. select doesn't help, because it doesn't narrow the generated return type here, and populate doesn't narrow nested relationships.

Could these JSON fields be generated with a serialisable JSON type (for example a recursive JsonValue) instead of unknown, at least when the TanStack adapter is used?

Which area(s) are affected?

area: core, framework: tanstack-start

Environment Info
payload: 4.0.0-beta.10
@payloadcms/tanstack-start: 4.0.0-beta.10
@payloadcms/db-postgres: 4.0.0-beta.10
@tanstack/react-start: 1.169.x
typescript: 6.0.3
node: 24
主要言語
TypeScript
スター
45.8k
フォーク
4.4k
平均マージ
3日 4時間
マージ済み PR(30日)
210

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

payloadcms/payload のほかの issue

payloadcms/payload の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。