payloadcms / payloadcms/payload

FIELD-TYPE-GUARDS.md imports field type guards from wrong package in code examples

Open
#16,909 0 comments 0 reactions 1 assignee View on GitHub

@zubricks is already working on this.

Since Jun 6, 2026.

Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Documentation Issue

Summary:

The reference documentation for field type guards in tools/claude-plugin/skills/payload/reference/FIELD-TYPE-GUARDS.md currently imports guard functions like fieldAffectsData and fieldHasSubFields from payload, but these helpers are actually exported from payload/shared, which matches current usage throughout the repository. This can cause confusion for users copying the examples and leads to import errors or mismatches with the actual codebase.

Additional Details

  • The location of the affected documentation is:
    • tools/claude-plugin/skills/payload/reference/FIELD-TYPE-GUARDS.md
    • (Potentially also: tools/claude-plugin/skills/payload/reference/FIELDS.md)
  • Current examples use imports like:
    import type { Field } from 'payload'
    import { fieldHasSubFields } from 'payload'
    import { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload'
    
  • Actual working usage should be:
    import type { Field } from 'payload'
    import { fieldHasSubFields } from 'payload/shared'
    import { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload/shared'
    
  • This matches both the export source (packages/payload/src/exports/shared.ts) and existing usage in core packages (graphql, drizzle, UI, plugin-import-export, etc).

Suggested fix:

  • Update all code samples in FIELD-TYPE-GUARDS.md (and optionally FIELDS.md) to use payload/shared for field guard helpers while keeping types imported from payload.
  • This will help keep docs in sync with current code and prevent copy-paste confusion for users.

Reference conversation:


Copilot conversation context: We found no open issues filing this discrepancy, but several export errors have affected users due to import/export mismatches (payload/shared, etc). This update would close a gap in the docs discovered during a code review.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.