Skip to content

draft: true doesn’t prevent TypeScript from expecting required fields #12578

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

Open
GermanJablo opened this issue May 27, 2025 · 0 comments
Open
Labels
created-by: Payload team status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@GermanJablo
Copy link
Contributor

Describe the Bug

According to the documentation, draft: true prevents mandatory fields from having to be defined, but TypeScript requires them anyway:

https://payloadcms.com/docs/versions/drafts#updating-or-creating-drafts

Link to the code that reproduces this issue

https://github.com/payloadcms/payload

Reproduction Steps

  1. In test/_community/collections/Posts/index.ts, add versions: { drafts: true } to the collection and required: true to the "content" field.
  2. Run pnpm dev to generate the types.
  3. You'll see an error in the second payload.create of the file: test/_community/config.ts. This error appears even if you add draft: true as a property to payload.create:
Type '{ title: string; }' is not assignable to type 'Omit<Post, "id" | "sizes" | "createdAt" | "updatedAt"> & Partial<Pick<Post, "id" | "sizes" | "createdAt" | "updatedAt">>'.
Property 'content' is missing in type '{ title: string; }' but required in type 'Omit<Post, "id" | "sizes" | "createdAt" | "updatedAt">'.ts(2322)

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Payload: 3.39.1
@GermanJablo GermanJablo added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels May 27, 2025
@github-actions github-actions bot added created-by: Payload team and removed validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
created-by: Payload team status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant