core-plugin-api: allow unknown plugin outputs for backwards compatibility

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-09 22:27:42 +02:00
parent 8208e3543a
commit d8c8f17be8
2 changed files with 19 additions and 2 deletions
+2 -1
View File
@@ -35,6 +35,7 @@ import {
BootErrorPageProps,
ErrorBoundaryFallbackProps,
} from './types';
import { BackstagePlugin } from '@backstage/core-plugin-api';
/**
* The default config loader, which expects that config is available at compile-time
@@ -171,7 +172,7 @@ export function createApp(options?: AppOptions) {
return new PrivateAppImpl({
apis,
icons,
plugins,
plugins: plugins as BackstagePlugin<any, any>[],
components,
themes,
configLoader,
+17 -1
View File
@@ -24,6 +24,7 @@ import {
RouteRef,
SubRouteRef,
ExternalRouteRef,
PluginOutput,
} from '@backstage/core-plugin-api';
import { AppConfig } from '@backstage/config';
import { AppIcons } from './icons';
@@ -131,6 +132,21 @@ export type AppRouteBinder = <
>,
) => void;
// Output from newer or older plugin API versions that might not be supported by
// this version of the app API, but we don't want to break at the type checking level.
// We only use this more permissive type for the `createApp` options, as we otherwise
// want to stick to using the type for the outputs that we know about in this version
// of the app api.
type UnknownPluginOutput = {
type: string;
};
export type BackstagePluginWithAnyOutput = Omit<
BackstagePlugin<any, any>,
'output'
> & {
output(): (PluginOutput | UnknownPluginOutput)[];
};
export type AppOptions = {
/**
* A collection of ApiFactories to register in the application to either
@@ -146,7 +162,7 @@ export type AppOptions = {
/**
* A list of all plugins to include in the app.
*/
plugins?: BackstagePlugin<any, any>[];
plugins?: BackstagePluginWithAnyOutput[];
/**
* Supply components to the app to override the default ones.