From e7604d269fe15f06534e6c1ba5c7d847c11c4a5a Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Mon, 27 May 2024 18:44:54 +0200 Subject: [PATCH] [docs-infra] Avoid cryptic errors when tests don't exist (#42356) --- .../api-docs-builder/ApiBuilders/ComponentApiBuilder.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts index 549a6c901e0b72..5ad3416c3d59c8 100644 --- a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts @@ -286,7 +286,7 @@ async function annotateComponentDefinition(api: ReactApi, componentJsdoc: Annota } let inheritanceAPILink = null; - if (api.inheritance !== null) { + if (api.inheritance) { inheritanceAPILink = `[${api.inheritance.name} API](${ api.inheritance.apiPathname.startsWith('http') ? api.inheritance.apiPathname @@ -317,7 +317,7 @@ async function annotateComponentDefinition(api: ReactApi, componentJsdoc: Annota api.apiPathname.startsWith('http') ? api.apiPathname : `${HOST}${api.apiPathname}` })`, ); - if (api.inheritance !== null) { + if (api.inheritance) { markdownLines.push(`- inherits ${inheritanceAPILink}`); } @@ -777,6 +777,7 @@ export default async function generateComponentApi( reactApi.slots = []; reactApi.classes = []; reactApi.demos = componentInfo.getDemos(); + reactApi.inheritance = null; if (reactApi.demos.length === 0) { throw new Error( 'Unable to find demos. \n' + @@ -792,7 +793,8 @@ export default async function generateComponentApi( reactApi.spread = testInfo.spread ?? spread; reactApi.themeDefaultProps = testInfo.themeDefaultProps; reactApi.inheritance = componentInfo.getInheritance(testInfo.inheritComponent); - } catch (e) { + } catch (error: any) { + console.error(error.message); if (project.name.includes('grid')) { // TODO: Use `describeConformance` for the DataGrid components reactApi.forwardsRefTo = 'GridRoot';