Skip to content

Commit

Permalink
Fix type for getRoutesToMatch()
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Jan 23, 2022
1 parent 41c4d97 commit 9d652b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/kbn-typed-react-router-config/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export type TypeAsArgs<TObject> = keyof TObject extends never
: [TObject];

export type FlattenRoutesOf<TRoutes extends RouteMap> = Array<
Omit<ValuesType<MapRoutes<TRoutes>>, 'parents'>
ValuesType<{
[key in keyof MapRoutes<TRoutes>]: ValuesType<MapRoutes<TRoutes>[key]>;
}>
>;

export interface Router<TRoutes extends RouteMap> {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/apm/public/hooks/use_apm_params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export function useMaybeApmParams<TPath extends PathsOf<ApmRoutes>>(
path: TPath,
optional: true
): TypeOf<ApmRoutes, TPath> | undefined {
return useParams(path, optional);
return useParams(path, optional) as TypeOf<ApmRoutes, TPath> | undefined;
}

export function useApmParams<TPath extends PathsOf<ApmRoutes>>(
path: TPath
): TypeOf<ApmRoutes, TPath> {
return useParams(path)!;
return useParams(path)! as TypeOf<ApmRoutes, TPath>;
}

export function useAnyOfApmParams<TPaths extends Array<PathsOf<ApmRoutes>>>(
...paths: TPaths
): TypeOf<ApmRoutes, ValuesType<TPaths>> {
return useParams(...paths)!;
return useParams(...paths)! as TypeOf<ApmRoutes, ValuesType<TPaths>>;
}
2 changes: 0 additions & 2 deletions x-pack/plugins/apm/public/hooks/use_apm_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down

0 comments on commit 9d652b2

Please sign in to comment.