Skip to content

Commit 820a6ec

Browse files
authored
fix: ensure generated types for config.blocks are not undefined if no blocks defined (#11377)
Previously, if no `config.blocks` were defined, `blocks: undefined` would incorrectly be added to the generated types.
1 parent 0a1af45 commit 820a6ec

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/payload/src/utilities/configToJSONSchema.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,14 +1156,13 @@ export function configToJSONSchema(
11561156
)
11571157
: {}
11581158

1159-
let blocksDefinition: JSONSchema4 | undefined = undefined
1159+
const blocksDefinition: JSONSchema4 | undefined = {
1160+
type: 'object',
1161+
additionalProperties: false,
1162+
properties: {},
1163+
required: [],
1164+
}
11601165
if (config?.blocks?.length) {
1161-
blocksDefinition = {
1162-
type: 'object',
1163-
additionalProperties: false,
1164-
properties: {},
1165-
required: [],
1166-
}
11671166
for (const block of config.blocks) {
11681167
const blockFieldSchemas = fieldsToJSONSchema(
11691168
collectionIDFieldTypes,

0 commit comments

Comments
 (0)