Skip to content

Commit

Permalink
refactor(portable-text-edior): keep consistency in pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Aug 11, 2022
1 parent a6b26ca commit 80e2482
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ export function getPortableTextFeatures(
if (!blockType) {
throw new Error('Block type is not defined in this schema (required)')
}
const childrenField =
blockType &&
blockType.fields &&
(blockType.fields.find((field) => field.name === 'children') as
| {type: ArraySchemaType}
| undefined)
const childrenField = blockType.fields?.find((field) => field.name === 'children') as
| {type: ArraySchemaType}
| undefined
if (!childrenField) {
throw new Error('Children field for block type found in schema (required)')
}
const ofType = childrenField.type && childrenField.type.of
const ofType = childrenField.type.of
if (!ofType) {
throw new Error('Valid types for block children not found in schema (required)')
}
Expand Down

0 comments on commit 80e2482

Please sign in to comment.