From 5691532f891d4861e9874d56c36c6e9f1c45dc3f Mon Sep 17 00:00:00 2001 From: Brian Leathem Date: Wed, 24 Mar 2021 20:54:54 -0700 Subject: [PATCH 1/2] Changed the signature of createRoutableExtension to include null Signed-off-by: Brian Leathem --- packages/core-api/src/extensions/extensions.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core-api/src/extensions/extensions.tsx b/packages/core-api/src/extensions/extensions.tsx index c486bfd84a..191e4c4fb7 100644 --- a/packages/core-api/src/extensions/extensions.tsx +++ b/packages/core-api/src/extensions/extensions.tsx @@ -27,8 +27,11 @@ type ComponentLoader = sync: T; }; +// We do not use ComponentType as the return type, since it doesn't let us convey the children prop. +// ComponentType inserts children as an optional prop whether the inner component accepts it or not, +// making it impossible to make the usage of children type safe. export function createRoutableExtension< - T extends (props: any) => JSX.Element + T extends (props: any) => JSX.Element | null >(options: { component: () => Promise; mountPoint: RouteRef; @@ -70,6 +73,9 @@ export function createComponentExtension< return createReactExtension({ component }); } +// We do not use ComponentType as the return type, since it doesn't let us convey the children prop. +// ComponentType inserts children as an optional prop whether the inner component accepts it or not, +// making it impossible to make the usage of children type safe. export function createReactExtension< T extends (props: any) => JSX.Element | null >(options: { From 76deafd318f93de4824b04f9a5c85e19473a3f4b Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 25 Mar 2021 08:51:13 +0100 Subject: [PATCH 2/2] Added changeset Signed-off-by: blam --- .changeset/chilled-flies-speak.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chilled-flies-speak.md diff --git a/.changeset/chilled-flies-speak.md b/.changeset/chilled-flies-speak.md new file mode 100644 index 0000000000..fc647a4fd5 --- /dev/null +++ b/.changeset/chilled-flies-speak.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-api': patch +--- + +Changed the signature of `createRoutableExtension` to include null