core-api: switch to deprecating routing types rather than removing

This commit is contained in:
Patrik Oldsberg
2020-12-07 19:06:24 +01:00
parent d8d5a17dad
commit 0873ed2d06
4 changed files with 45 additions and 6 deletions
+6 -2
View File
@@ -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`.
+8 -2
View File
@@ -32,8 +32,14 @@ export class AbsoluteRouteRef<Params extends { [param in string]: string }> {
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() {
+7 -1
View File
@@ -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';
+24 -1
View File
@@ -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<Params extends { [param in string]: string } = {}> = {
// 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<any>;
/**
* 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 extends { [param in string]: string }> = {
params?: Array<keyof Params>;
path: string;