From 0755fc632dca52949719ed8b837af94016849898 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 4 Mar 2021 09:48:33 +0100 Subject: [PATCH] core-api: tweak route ref types Signed-off-by: Patrik Oldsberg --- packages/core-api/src/routing/RouteRef.ts | 7 ++++--- packages/core-api/src/routing/types.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/core-api/src/routing/RouteRef.ts b/packages/core-api/src/routing/RouteRef.ts index d218d72fbb..eda16ccc91 100644 --- a/packages/core-api/src/routing/RouteRef.ts +++ b/packages/core-api/src/routing/RouteRef.ts @@ -31,13 +31,14 @@ export type RouteRefConfig = { title: string; }; -class RouteRefBaseBase { +class RouteRefBase { constructor(type: string, id: string) { this.toString = () => `routeRef{type=${type},id=${id}}`; } } -export class RouteRefImpl extends RouteRefBaseBase { +export class RouteRefImpl extends RouteRefBase + implements RouteRef { readonly [routeRefType] = 'absolute'; constructor(private readonly config: RouteRefConfig) { @@ -92,7 +93,7 @@ export function createRouteRef< export class ExternalRouteRefImpl< Params extends AnyParams, Optional extends boolean -> extends RouteRefBaseBase { +> extends RouteRefBase implements ExternalRouteRef { readonly [routeRefType] = 'external'; constructor( diff --git a/packages/core-api/src/routing/types.ts b/packages/core-api/src/routing/types.ts index de6f991ec9..69de5345a5 100644 --- a/packages/core-api/src/routing/types.ts +++ b/packages/core-api/src/routing/types.ts @@ -28,7 +28,7 @@ export const routeRefType: unique symbol = getGlobalSingleton( ); export type RouteRef = { - [routeRefType]: 'absolute'; + readonly [routeRefType]: 'absolute'; params: ParamKeys; @@ -45,7 +45,7 @@ export type ExternalRouteRef< Params extends AnyParams = any, Optional extends boolean = any > = { - [routeRefType]: 'external'; + readonly [routeRefType]: 'external'; params: ParamKeys;