payloadcms / payloadcms/payload
generate:types crashes on object-form localization.locales (json-schema-to-typescript TypeError: endsWith of undefined)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
payload generate:types crashes with a TypeError inside json-schema-to-typescript when config-level localization.locales uses the object form ({ label, value }) and at least one collection has a localized field. The documented string-array form works fine in the identical config.
Link to the Code that Reproduces this Issue
Minimal config that crashes:
import { buildConfig } from "payload";
export default buildConfig({
localization: {
locales: [
{ label: "English", value: "en" },
{ label: "French", value: "fr" },
],
defaultLocale: "en",
fallback: true,
},
collections: [
{
slug: "posts",
fields: [{ name: "title", type: "text", localized: true }],
},
],
});
Swapping locales to ["en", "fr"] makes generate:types succeed — everything else unchanged.
Reproduction Steps
pnpm dlx create-payload-app@latest(or any Payload 3.88.0 project).- Set
localization.localesto the object form above and add one localized field. - Run
pnpm payload generate:types.
Expected / Actual Behaviors
Expected: types are generated for either documented locale form.
Actual: with the object form:
Error generating types: TypeError: Cannot read properties of undefined (reading 'endsWith')
... json-schema-to-typescript ...
Environment Info
Output of npx payload info:
Binaries:
Node: 22.22.2
npm: 10.9.2
Yarn: N/A
pnpm: 10.x
Relevant Packages:
payload: 3.88.0
next: 16.3.1
@payloadcms/ui: 3.88.0
react: 19.x
typescript: 5.7.3
json-schema-to-typescript: 15.0.3 (payload dependency)
Operating System: macOS 15.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the documented object-form localization.locales and a localized field, then trace the generate:types entry point into its localized-field schema generation. Check how json-schema-to-typescript receives the locale data. Done means generation succeeds for both the object and string-array locale forms, with the existing configuration unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100