Skip to content

Commit 88eeeaa

Browse files
authored
fix: incorrect types for field Label, Description and Error server components (#11642)
Our previous types for Label, Description and Error server components were incorrectly typed. We were using the `ServerProps` type, which was wrong. In our renderFields function, you can see that `ServerComponentProps` are passed as server props, not `ServerProps`: https://github.com/payloadcms/payload/blob/fix/incorrect-component-types/packages/ui/src/forms/fieldSchemasToFormState/renderField.tsx Additionally, we no longer have to wrap that type in `Partial<>`, as all server props in that type are required.
1 parent d14bc44 commit 88eeeaa

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { TFunction } from '@payloadcms/translations'
22

3-
import type { ServerProps } from '../../config/types.js'
43
import type { Field } from '../../fields/config/types.js'
5-
import type { ClientFieldWithOptionalType } from './Field.js'
4+
import type { ClientFieldWithOptionalType, ServerComponentProps } from './Field.js'
65

76
export type DescriptionFunction = ({ t }: { t: TFunction }) => string
87

@@ -33,7 +32,7 @@ export type FieldDescriptionServerProps<
3332
clientField: TFieldClient
3433
readonly field: TFieldServer
3534
} & GenericDescriptionProps &
36-
Partial<ServerProps>
35+
ServerComponentProps
3736

3837
export type FieldDescriptionClientProps<
3938
TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { ServerProps } from '../../config/types.js'
21
import type { Field } from '../../fields/config/types.js'
3-
import type { ClientFieldWithOptionalType } from './Field.js'
2+
import type { ClientFieldWithOptionalType, ServerComponentProps } from './Field.js'
43

54
export type GenericErrorProps = {
65
readonly alignCaret?: 'center' | 'left' | 'right'
@@ -22,7 +21,7 @@ export type FieldErrorServerProps<
2221
clientField: TFieldClient
2322
readonly field: TFieldServer
2423
} & GenericErrorProps &
25-
Partial<ServerProps>
24+
ServerComponentProps
2625

2726
export type FieldErrorClientComponent<
2827
TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { ServerProps, StaticLabel } from '../../config/types.js'
1+
import type { StaticLabel } from '../../config/types.js'
22
import type { Field } from '../../fields/config/types.js'
3-
import type { ClientFieldWithOptionalType } from './Field.js'
3+
import type { ClientFieldWithOptionalType, ServerComponentProps } from './Field.js'
44

55
export type GenericLabelProps = {
66
readonly as?: 'label' | 'span'
@@ -26,7 +26,7 @@ export type FieldLabelServerProps<
2626
clientField: TFieldClient
2727
readonly field: TFieldServer
2828
} & GenericLabelProps &
29-
Partial<ServerProps>
29+
ServerComponentProps
3030

3131
export type SanitizedLabelProps<TFieldClient extends ClientFieldWithOptionalType> = Omit<
3232
FieldLabelClientProps<TFieldClient>,

0 commit comments

Comments
 (0)