frontend-plugin-api: fix useRouteRef types for optional external route refs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-04-09 14:27:12 +02:00
parent 08122fd400
commit 35452b3650
3 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/frontend-plugin-api': patch
---
Fixed the type for `useRouteRef`, which wasn't handling optional external route refs correctly.
+1 -1
View File
@@ -1155,7 +1155,7 @@ export function useRouteRef<
TParams extends AnyRouteRefParams,
>(
routeRef: ExternalRouteRef<TParams, TOptional>,
): TParams extends true ? RouteFunc<TParams> | undefined : RouteFunc<TParams>;
): TOptional extends true ? RouteFunc<TParams> | undefined : RouteFunc<TParams>;
// @public
export function useRouteRef<TParams extends AnyRouteRefParams>(
@@ -38,7 +38,7 @@ export function useRouteRef<
TParams extends AnyRouteRefParams,
>(
routeRef: ExternalRouteRef<TParams, TOptional>,
): TParams extends true ? RouteFunc<TParams> | undefined : RouteFunc<TParams>;
): TOptional extends true ? RouteFunc<TParams> | undefined : RouteFunc<TParams>;
/**
* React hook for constructing URLs to routes.