From 075a9a067bfbd4296dc9a7bfd16845d6c6b6d583 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Mon, 25 Apr 2022 15:10:00 +0200 Subject: [PATCH 1/2] Clean up createTechDocsAddonExtension return type Signed-off-by: Eric Peterson --- .changeset/techdocs-touch-screen-wipes.md | 5 +++++ plugins/techdocs-module-addons-contrib/api-report.md | 3 +-- plugins/techdocs-react/api-report.md | 2 +- plugins/techdocs-react/src/addons.tsx | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changeset/techdocs-touch-screen-wipes.md diff --git a/.changeset/techdocs-touch-screen-wipes.md b/.changeset/techdocs-touch-screen-wipes.md new file mode 100644 index 0000000000..0165e6c9bc --- /dev/null +++ b/.changeset/techdocs-touch-screen-wipes.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-react': patch +--- + +Updated the return type of `createTechDocsAddonExtension` to better reflect the fact that passing children to Addon components is not a valid use-case. diff --git a/plugins/techdocs-module-addons-contrib/api-report.md b/plugins/techdocs-module-addons-contrib/api-report.md index 264f12970b..076b05957c 100644 --- a/plugins/techdocs-module-addons-contrib/api-report.md +++ b/plugins/techdocs-module-addons-contrib/api-report.md @@ -6,10 +6,9 @@ /// import { BackstagePlugin } from '@backstage/core-plugin-api'; -import { ComponentType } from 'react'; // @public -export const ReportIssue: ComponentType; +export const ReportIssue: (props: ReportIssueProps) => JSX.Element | null; // @public (undocumented) export type ReportIssueProps = { diff --git a/plugins/techdocs-react/api-report.md b/plugins/techdocs-react/api-report.md index 29bbf7234b..264d59146e 100644 --- a/plugins/techdocs-react/api-report.md +++ b/plugins/techdocs-react/api-report.md @@ -17,7 +17,7 @@ import { SetStateAction } from 'react'; // @alpha export function createTechDocsAddonExtension( options: TechDocsAddonOptions, -): Extension>; +): Extension<(props: TComponentProps) => JSX.Element | null>; // @alpha (undocumented) export const defaultTechDocsReaderPageValue: TechDocsReaderPageValue; diff --git a/plugins/techdocs-react/src/addons.tsx b/plugins/techdocs-react/src/addons.tsx index 54d4f92e2f..39d110bee3 100644 --- a/plugins/techdocs-react/src/addons.tsx +++ b/plugins/techdocs-react/src/addons.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, { ComponentType, useCallback } from 'react'; +import React, { useCallback } from 'react'; import { useOutlet } from 'react-router-dom'; import { @@ -53,7 +53,7 @@ const getDataKeyByName = (name: string) => { */ export function createTechDocsAddonExtension( options: TechDocsAddonOptions, -): Extension> { +): Extension<(props: TComponentProps) => JSX.Element | null> { const { name, component: TechDocsAddon } = options; return createReactExtension({ name, From f99a346a5d6e608de6b0269e14254e4f5839ec3c Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Mon, 25 Apr 2022 16:13:05 +0200 Subject: [PATCH 2/2] Fix type dependencies per warning. Signed-off-by: Eric Peterson --- .changeset/techdocs-touch-screen-wipes.md | 1 + plugins/techdocs-module-addons-contrib/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/techdocs-touch-screen-wipes.md b/.changeset/techdocs-touch-screen-wipes.md index 0165e6c9bc..b6467a4232 100644 --- a/.changeset/techdocs-touch-screen-wipes.md +++ b/.changeset/techdocs-touch-screen-wipes.md @@ -1,5 +1,6 @@ --- '@backstage/plugin-techdocs-react': patch +'@backstage/plugin-techdocs-module-addons-contrib': patch --- Updated the return type of `createTechDocsAddonExtension` to better reflect the fact that passing children to Addon components is not a valid use-case. diff --git a/plugins/techdocs-module-addons-contrib/package.json b/plugins/techdocs-module-addons-contrib/package.json index c9695c40e2..6408ee4797 100644 --- a/plugins/techdocs-module-addons-contrib/package.json +++ b/plugins/techdocs-module-addons-contrib/package.json @@ -47,7 +47,6 @@ "react-use": "^17.2.4" }, "peerDependencies": { - "@types/react": "^16.13.1 || ^17.0.0", "react": "^16.13.1 || ^17.0.0" }, "devDependencies": { @@ -60,6 +59,7 @@ "@testing-library/user-event": "^14.0.0", "@types/jest": "^26.0.7", "@types/node": "^16.11.26", + "@types/react": "^16.13.1 || ^17.0.0", "msw": "^0.35.0", "cross-fetch": "^3.1.5" },