From 0873ed2d06b885c29a445cfdb2f8425ad18b96ec Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 7 Dec 2020 19:06:24 +0100 Subject: [PATCH] core-api: switch to deprecating routing types rather than removing --- .changeset/red-worms-fold.md | 8 ++++++-- packages/core-api/src/routing/RouteRef.ts | 10 +++++++-- packages/core-api/src/routing/index.ts | 8 +++++++- packages/core-api/src/routing/types.ts | 25 ++++++++++++++++++++++- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.changeset/red-worms-fold.md b/.changeset/red-worms-fold.md index 081f686659..41dcc75c4c 100644 --- a/.changeset/red-worms-fold.md +++ b/.changeset/red-worms-fold.md @@ -1,5 +1,9 @@ --- -'@backstage/core-api': minor +'@backstage/core-api': patch --- -Remove exported `ConcreteRoute`, `MutableRouteRef`, `AbsoluteRouteRef` types, and add as of yet unused `params` option to `createRouteRef`. +Deprecated the `ConcreteRoute`, `MutableRouteRef`, `AbsoluteRouteRef` types and added a new `RouteRef` type as replacement. + +Deprecated and disabled the `createSubRoute` method of `AbsoluteRouteRef`. + +Add an as of yet unused `params` option to `createRouteRef`. diff --git a/packages/core-api/src/routing/RouteRef.ts b/packages/core-api/src/routing/RouteRef.ts index 41384cafe2..0fbc57c6f1 100644 --- a/packages/core-api/src/routing/RouteRef.ts +++ b/packages/core-api/src/routing/RouteRef.ts @@ -32,8 +32,14 @@ export class AbsoluteRouteRef { return this.config.title; } - get P(): Params { - throw new Error("Don't call me maybe"); + /** + * This function should not be used, create a separate RouteRef instead + * @deprecated + */ + createSubRoute(): any { + throw new Error( + 'This method should not be called, create a separate RouteRef instead', + ); } toString() { diff --git a/packages/core-api/src/routing/index.ts b/packages/core-api/src/routing/index.ts index 1493507f4e..d682aa9348 100644 --- a/packages/core-api/src/routing/index.ts +++ b/packages/core-api/src/routing/index.ts @@ -14,5 +14,11 @@ * limitations under the License. */ -export type { RouteRef, RouteRefConfig } from './types'; +export type { + RouteRef, + RouteRefConfig, + AbsoluteRouteRef, + ConcreteRoute, + MutableRouteRef, +} from './types'; export { createRouteRef } from './RouteRef'; diff --git a/packages/core-api/src/routing/types.ts b/packages/core-api/src/routing/types.ts index 2726504ad2..e91ca7ea53 100644 --- a/packages/core-api/src/routing/types.ts +++ b/packages/core-api/src/routing/types.ts @@ -16,16 +16,39 @@ import { IconComponent } from '../icons'; +// @ts-ignore, we're just embedding the Params type for usage in other places export type RouteRef = { // TODO(Rugvip): Remove path, look up via registry instead path: string; icon?: IconComponent; title: string; - P: Params; + /** + * This function should not be used, create a separate RouteRef instead + * @deprecated + */ + createSubRoute(): any; }; export type AnyRouteRef = RouteRef; +/** + * This type should not be used + * @deprecated + */ +export type ConcreteRoute = {}; + +/** + * This type should not be used, use RouteRef instead + * @deprecated + */ +export type AbsoluteRouteRef = RouteRef<{}>; + +/** + * This type should not be used, use RouteRef instead + * @deprecated + */ +export type MutableRouteRef = RouteRef<{}>; + export type RouteRefConfig = { params?: Array; path: string;