diff --git a/db/model/Gdoc/extractGdocComponentInfo.ts b/db/model/Gdoc/extractGdocComponentInfo.ts index 5b3d2182be1..8c64d2d2ac1 100644 --- a/db/model/Gdoc/extractGdocComponentInfo.ts +++ b/db/model/Gdoc/extractGdocComponentInfo.ts @@ -68,11 +68,15 @@ function iterateArrayProp( parentPath: string, prop: keyof T ): ChildIterationInfo[] { - return (parent[prop] as OwidEnrichedGdocBlock[]).map((child, index) => ({ - child: child, - parentPath: `${parentPath}`, - path: `${parentPath}.${String(prop)}[${index}]`, - })) + if (parent[prop]) + 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.