Skip to content

Commit c28618b

Browse files
authored
fix: requires client field prop in server field components (#8188)
Fixes a type error when using server components for field labels, descriptions, and errors. The `clientField` prop will always exist, so the types just need to be reflective of this. Here's an example: ```tsx import type { TextFieldServerLabelComponent } from 'payload' import { FieldLabel } from '@payloadcms/ui' import React from 'react' export const MyServerFieldLabelComponent: TextFieldServerLabelComponent = ({ clientField }) => { return <FieldLabel field={clientField} /> // `TextFieldClientWithoutType | undefined` is not assignable to type `ClientFieldWithoutType` } ```
1 parent 945d919 commit c28618b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/payload/src/admin/forms/Description.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type FieldDescriptionServerProps<
2929
TFieldServer extends Field = Field,
3030
TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,
3131
> = {
32-
clientField?: TFieldClient
32+
clientField: TFieldClient
3333
readonly field: TFieldServer
3434
} & GenericDescriptionProps &
3535
Partial<ServerProps>

packages/payload/src/admin/forms/Error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type FieldErrorServerProps<
2121
TFieldServer extends Field,
2222
TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,
2323
> = {
24-
clientField?: TFieldClient
24+
clientField: TFieldClient
2525
readonly field: TFieldServer
2626
} & GenericErrorProps &
2727
Partial<ServerProps>

packages/payload/src/admin/forms/Label.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type FieldLabelServerProps<
2222
TFieldServer extends Field,
2323
TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,
2424
> = {
25-
clientField?: TFieldClient
25+
clientField: TFieldClient
2626
readonly field: TFieldServer
2727
} & GenericLabelProps &
2828
Partial<ServerProps>

0 commit comments

Comments
 (0)