From 9d652b25b464f40fee428ffd6e2a89102c6d668f Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Sun, 23 Jan 2022 13:28:04 +0100 Subject: [PATCH] Fix type for getRoutesToMatch() --- packages/kbn-typed-react-router-config/src/types/index.ts | 4 +++- x-pack/plugins/apm/public/hooks/use_apm_params.ts | 6 +++--- x-pack/plugins/apm/public/hooks/use_apm_router.ts | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/kbn-typed-react-router-config/src/types/index.ts b/packages/kbn-typed-react-router-config/src/types/index.ts index 647860631725bd..a5121ba0d72c94 100644 --- a/packages/kbn-typed-react-router-config/src/types/index.ts +++ b/packages/kbn-typed-react-router-config/src/types/index.ts @@ -106,7 +106,9 @@ export type TypeAsArgs = keyof TObject extends never : [TObject]; export type FlattenRoutesOf = Array< - Omit>, 'parents'> + ValuesType<{ + [key in keyof MapRoutes]: ValuesType[key]>; + }> >; export interface Router { diff --git a/x-pack/plugins/apm/public/hooks/use_apm_params.ts b/x-pack/plugins/apm/public/hooks/use_apm_params.ts index b4c17c1b329aed..89aca1e4bf1a6f 100644 --- a/x-pack/plugins/apm/public/hooks/use_apm_params.ts +++ b/x-pack/plugins/apm/public/hooks/use_apm_params.ts @@ -16,17 +16,17 @@ export function useMaybeApmParams>( path: TPath, optional: true ): TypeOf | undefined { - return useParams(path, optional); + return useParams(path, optional) as TypeOf | undefined; } export function useApmParams>( path: TPath ): TypeOf { - return useParams(path)!; + return useParams(path)! as TypeOf; } export function useAnyOfApmParams>>( ...paths: TPaths ): TypeOf> { - return useParams(...paths)!; + return useParams(...paths)! as TypeOf>; } diff --git a/x-pack/plugins/apm/public/hooks/use_apm_router.ts b/x-pack/plugins/apm/public/hooks/use_apm_router.ts index dea66d7b2e1c89..d10b6da8578027 100644 --- a/x-pack/plugins/apm/public/hooks/use_apm_router.ts +++ b/x-pack/plugins/apm/public/hooks/use_apm_router.ts @@ -14,8 +14,6 @@ export function useApmRouter() { const { core } = useApmPluginContext(); const link = (...args: [any]) => { - // @ts-expect-error router.link() expects never type, because - // no routes are specified. that's okay. return core.http.basePath.prepend('/app/apm' + router.link(...args)); };