tanstack-start: generated JSON fields typed as unknown (`_transforms`, session `metadata`) break createServerFn's serialisable return check in 4.0.0-beta.10
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 45.8k
- Fork
- 4.4k
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 210
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của payloadcms/payload
-
area: ui Bug Payload OSS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
payloadcms/payload#19839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Accessibility: list row and select-all checkboxes still unnamed in 3.x (#17376 fix not in 3.91)Đang mởBug Payload OSS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
payloadcms/payload#19837 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Payload OSS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
payloadcms/payload#19835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Payload OSS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
payloadcms/payload#19833 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Payload OSS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
payloadcms/payload#19832 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của payloadcms/payload
Issue tương tự
-
[BUG]: Shared links drop the configured basePath on GitHub PagesCó thể đã có người làm @anshulchikhale30-p đã nhận hôm nay. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: GTrekkerĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Maintainer thường phản hồi trong vòng 1 ngày