Skip to content

Type error in seed/route.ts during build with PostgreSQL + Website template (User & { collection: "users" } not assignable) #13021

Open
@dalir-bajelani

Description

@dalir-bajelani

Link to reproduction

No response

Describe the Bug

When using the website template with PostgreSQL as the database, a type error occurs during pnpm run build. The error is related to the user object passed to createLocalReq() in src/app/(frontend)/next/seed/route.ts.

Error:
Type error: Type 'User & { collection: "users"; }' is not assignable to type 'User | null | undefined'. Type 'User & { collection: "users"; }' is not assignable to type 'User'. Type 'User & { collection: "users"; }' is not assignable to type 'BaseUser'. Types of property 'sessions' are incompatible. Type '{ id: string; createdAt?: string | null | undefined; expiresAt: string; }[] | null | undefined' is not assignable to type 'UserSession[] | undefined'. Type 'null' is not assignable to type 'UserSession[] | undefined'.

To Reproduce

  1. pnpx create-payload-app@latest
  2. Choose:
  • Template: website
  • Database: PostgreSQL
  1. Then run:
    pnpm install pnpm run build
  2. Build fails with type error in src/app/(frontend)/next/seed/route.ts

Node.js version: v22.16.0

Payload Version

3.44.0

Adapters and Plugins

db-postgres

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yetv2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions