Merge pull request #5095 from bleathem/createRoutableExtension-signature

Changed the signature of createRoutableExtension to include null
This commit is contained in:
Patrik Oldsberg
2021-03-25 10:06:33 +01:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-api': patch
---
Changed the signature of `createRoutableExtension` to include null
@@ -27,8 +27,11 @@ type ComponentLoader<T> =
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<T>;
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: {