core: remove usage of explicit type parameters for BackstagePlugin

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-07-12 10:19:21 +02:00
parent 1c2fed4239
commit 881fc75a75
10 changed files with 27 additions and 23 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/app-defaults': patch
'@backstage/core-app-api': patch
'@backstage/core-plugin-api': patch
---
Internal tweak removing usage of explicit type parameters for the `BackstagePlugin` type.
+1 -1
View File
@@ -74,7 +74,7 @@ The extension type is a simple one:
```ts
export type Extension<T> = {
expose(plugin: BackstagePlugin<any, any>): T;
expose(plugin: BackstagePlugin): T;
};
```
+1 -1
View File
@@ -50,7 +50,7 @@ export function createApp(
...icons,
...options?.icons,
},
plugins: (options?.plugins as BackstagePlugin<any, any>[]) ?? [],
plugins: (options?.plugins as BackstagePlugin[]) ?? [],
themes: options?.themes ?? themes,
});
}
+3 -3
View File
@@ -155,7 +155,7 @@ export type AppConfigLoader = () => Promise<AppConfig[]>;
// @public
export type AppContext = {
getPlugins(): BackstagePlugin<any, any>[];
getPlugins(): BackstagePlugin[];
getSystemIcon(key: string): IconComponent | undefined;
getComponents(): AppComponents;
};
@@ -193,7 +193,7 @@ export type AppOptions = {
[key in string]: IconComponent;
};
plugins?: Array<
BackstagePlugin<any, any> & {
BackstagePlugin & {
output?(): Array<
| {
type: 'feature-flag';
@@ -254,7 +254,7 @@ export type AuthApiCreateOptions = {
// @public
export type BackstageApp = {
getPlugins(): BackstagePlugin<any, any>[];
getPlugins(): BackstagePlugin[];
getSystemIcon(key: string): IconComponent | undefined;
getProvider(): ComponentType<{}>;
getRouter(): ComponentType<{}>;
+6 -6
View File
@@ -82,8 +82,8 @@ import { resolveRouteBindings } from './resolveRouteBindings';
import { BackstageRouteObject } from '../routing/types';
type CompatiblePlugin =
| BackstagePlugin<any, any>
| (Omit<BackstagePlugin<any, any>, 'getFeatureFlags'> & {
| BackstagePlugin
| (Omit<BackstagePlugin, 'getFeatureFlags'> & {
output(): Array<{ type: 'feature-flag'; name: string }>;
});
@@ -145,7 +145,7 @@ function useConfigLoader(
class AppContextImpl implements AppContext {
constructor(private readonly app: AppManager) {}
getPlugins(): BackstagePlugin<any, any>[] {
getPlugins(): BackstagePlugin[] {
return this.app.getPlugins();
}
@@ -186,8 +186,8 @@ export class AppManager implements BackstageApp {
this.apiFactoryRegistry = new ApiFactoryRegistry();
}
getPlugins(): BackstagePlugin<any, any>[] {
return Array.from(this.plugins) as BackstagePlugin<any, any>[];
getPlugins(): BackstagePlugin[] {
return Array.from(this.plugins) as BackstagePlugin[];
}
getSystemIcon(key: string): IconComponent | undefined {
@@ -241,7 +241,7 @@ export class AppManager implements BackstageApp {
validateRouteParameters(routing.paths, routing.parents);
validateRouteBindings(
routeBindings,
this.plugins as Iterable<BackstagePlugin<any, any>>,
this.plugins as Iterable<BackstagePlugin>,
);
}
+3 -3
View File
@@ -206,7 +206,7 @@ export type AppOptions = {
* A list of all plugins to include in the app.
*/
plugins?: Array<
BackstagePlugin<any, any> & {
BackstagePlugin & {
output?(): Array<
{ type: 'feature-flag'; name: string } | { type: string }
>; // support for old plugins
@@ -291,7 +291,7 @@ export type BackstageApp = {
/**
* Returns all plugins registered for the app.
*/
getPlugins(): BackstagePlugin<any, any>[];
getPlugins(): BackstagePlugin[];
/**
* Get a common or custom icon for this app.
@@ -321,7 +321,7 @@ export type AppContext = {
/**
* Get a list of all plugins that are installed in the app.
*/
getPlugins(): BackstagePlugin<any, any>[];
getPlugins(): BackstagePlugin[];
/**
* Get a common or custom icon for this app.
@@ -18,12 +18,9 @@ import { BackstagePlugin, getComponentData } from '@backstage/core-plugin-api';
import { createCollector } from '../extensions/traversal';
export const pluginCollector = createCollector(
() => new Set<BackstagePlugin<any, any>>(),
() => new Set<BackstagePlugin>(),
(acc, node) => {
const plugin = getComponentData<BackstagePlugin<any, any>>(
node,
'core.plugin',
);
const plugin = getComponentData<BackstagePlugin>(node, 'core.plugin');
if (plugin) {
acc.add(plugin);
}
+2 -2
View File
@@ -147,7 +147,7 @@ export type AppComponents = {
// @public
export type AppContext = {
getPlugins(): BackstagePlugin_2<any, any>[];
getPlugins(): BackstagePlugin_2[];
getSystemIcon(key: string): IconComponent_2 | undefined;
getComponents(): AppComponents;
};
@@ -401,7 +401,7 @@ export type ErrorBoundaryFallbackProps = {
// @public
export type Extension<T> = {
expose(plugin: BackstagePlugin<any, any>): T;
expose(plugin: BackstagePlugin): T;
};
// @public
@@ -225,7 +225,7 @@ export function createReactExtension<
'Component';
return {
expose(plugin: BackstagePlugin<any, any>) {
expose(plugin: BackstagePlugin) {
const Result: any = (props: any) => {
const app = useApp();
const { Progress } = app.getComponents();
+1 -1
View File
@@ -27,7 +27,7 @@ import { AnyApiFactory } from '../apis/system';
* @public
*/
export type Extension<T> = {
expose(plugin: BackstagePlugin<any, any>): T;
expose(plugin: BackstagePlugin): T;
};
/**