Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: improve type safety for siblingData in field types#14895

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Rot4tion wants to merge5 commits intopayloadcms:main
base:main
Choose a base branch
Loading
fromRot4tion:feat/improve-siblingdata-type-safety-strip-relationships

Conversation

@Rot4tion
Copy link
Contributor

Summary

Improves TypeScript type safety forsiblingData across field configuration types by introducing a StripRelationships utility type that removes populated relationship objects, keeping the ID type (number orstring) base on database config.

constsiblingData={creator:1,// Relationship field_status:'draft',title:"abc",updatedAt:'2025-12-11T07:52:22.115Z',createdAt:'2025-12-11T07:13:24.433Z',attributes:[3,2],// Relationship hasManydescription:{// RichText fieldroot:{type:'root',children:[...],}},}}// RichText field// Before (Incorrect Types)typeSiblingData={[key:string]:any}|undefined// Or with Partial<TData>:typeSiblingData={creator:number|User|undefined// ❌ Includes populated objectattributes?:(number|Attribute)[]// ❌ Includes populated objects  ...}// After (Correct Types)typeSiblingData={id:number|undefinedcreator:number|undefined// ✅ ID onlytitle:string|undefineddescription:{[k:string]:unknownroot:{type:stringchildren:{type:any;version:number}[]direction:'rtl'|'ltr'|nullformat:''|'center'|'left'|'right'|'start'|'end'|'justify'indent:numberversion:number}}|undefinedattributes?:number[]|null// ✅ IDs onlyupdatedAt:string|undefinedcreatedAt:string|undefined_status?:"draft"|"published"|null}

}from'../validations.js'

exporttypeFieldHookArgs<TDataextendsTypeWithID=any,TValue=any,TSiblingData=any>={
exporttypeFieldHookArgs<TDataextendsTypeWithID=any,TValue=any,TSiblingData=TData>={
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

TData !== TSiblingData if you're in a group field. I'd rather have it typed weakly (any) than potentially incorrectly

Copy link
ContributorAuthor

@Rot4tionRot4tionDec 13, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i see the issue, pls check my new commit

imageimage

Rollback TSiblingData generic parameter default from `TData` to `any` across FieldHookArgs, FieldHook, FieldAccessArgs, FieldAccess, Condition, and FilterOptionsProps types. This allows siblingData to have a different type than the top-level document data, improving type flexibility for nested field structures.Add TSiblingData type to FilterOptionsProps
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@AlessioGrAlessioGrAlessioGr left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Rot4tion@AlessioGr

[8]ページ先頭

©2009-2025 Movatter.jp