tanstack-start: generated JSON fields typed as unknown (`_transforms`, session `metadata`) break createServerFn's serialisable return check in 4.0.0-beta.10
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
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):
_transformson every upload collection (UploadTransforms.encoding: { [k: string]: unknown })sessions[].metadataon auth collections ({ [k: string]: unknown } | unknown[] | ...), which reaches every document through thecreatedBy/updatedByrelationships 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
- Create a TanStack Start project on
4.0.0-beta.10with an upload collection. - Run
payload generate:types. - 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
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
payloadcms/payload のほかの issue
-
area: ui Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
payloadcms/payload#19839 ·
メンテナーはふだん 1 日以内に返信
-
Accessibility: list row and select-all checkboxes still unnamed in 3.x (#17376 fix not in 3.91)オープンBug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
payloadcms/payload#19837 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19835 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19833 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19832 ·
メンテナーはふだん 1 日以内に返信
payloadcms/payload の issue をすべて見る
似ている issue
-
[BUG]: Shared links drop the configured basePath on GitHub Pages対応中かも @anshulchikhale30-p が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add: GTrekkerオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
メンテナーはふだん 1 日以内に返信