Skip to content

Commit

Permalink
🐛 fix bug in gdoc component extraction code
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Dec 16, 2024
1 parent c57f904 commit 155077f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions db/model/Gdoc/extractGdocComponentInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ function iterateArrayProp<T extends OwidEnrichedGdocBlock>(
parentPath: string,
prop: keyof T
): ChildIterationInfo[] {
return (parent[prop] as OwidEnrichedGdocBlock[]).map((child, index) => ({
child: child,
parentPath: `${parentPath}`,
path: `${parentPath}.${String(prop)}[${index}]`,
}))
if (prop in parent)
return (parent[prop] as OwidEnrichedGdocBlock[]).map(
(child, index) => ({
child: child,
parentPath: `${parentPath}`,
path: `${parentPath}.${String(prop)}[${index}]`,
})
)
else return []
}

/** Convert the spans in a gdoc component to plain text.
Expand Down

0 comments on commit 155077f

Please sign in to comment.