Change signature of Plugin.stop to maybe async (#170225)

## Summary

Fix https://github.com/elastic/kibana/issues/83612

This PR doesn't change any behavior, as we're already supporting (and
awaiting) promises returned from `stop` calls to plugin, it just changes
the type's signature to reflect that.

Also removed empty `stop` methods from existing plugins to make
typescript happy.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Pierre Gayvallet 2023-11-06 09:38:19 +01:00 committed by GitHub
parent 9def79267c
commit d64e246cb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 7 additions and 25 deletions

View file

@ -83,8 +83,4 @@ export class FeatureControlsPluginExample
start() {
return {};
}
stop() {
return {};
}
}

View file

@ -76,8 +76,4 @@ export class UserProfilesPlugin implements Plugin<void, void, SetupDeps, StartDe
start() {
return {};
}
stop() {
return {};
}
}

View file

@ -6,6 +6,7 @@
* Side Public License, v 1.
*/
import type { MaybePromise } from '@kbn/utility-types';
import type { CoreStart, CoreSetup } from '@kbn/core-lifecycle-browser';
/**
@ -23,5 +24,5 @@ export interface Plugin<
start(core: CoreStart, plugins: TPluginsStart): TStart;
stop?(): void;
stop?(): MaybePromise<void>;
}

View file

@ -16,6 +16,7 @@
"@kbn/core-base-common",
"@kbn/core-lifecycle-browser",
"@kbn/logging",
"@kbn/utility-types",
],
"exclude": [
"target/**/*",

View file

@ -8,7 +8,7 @@
import { Observable } from 'rxjs';
import { Type } from '@kbn/config-schema';
import type { RecursiveReadonly } from '@kbn/utility-types';
import type { RecursiveReadonly, MaybePromise } from '@kbn/utility-types';
import type { PathConfigType } from '@kbn/utils';
import type { LoggerFactory } from '@kbn/logging';
import type {
@ -297,7 +297,7 @@ export interface Plugin<
start(core: CoreStart, plugins: TPluginsStart): TStart;
stop?(): void;
stop?(): MaybePromise<void>;
}
/**
@ -317,7 +317,7 @@ export interface AsyncPlugin<
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
stop?(): void;
stop?(): MaybePromise<void>;
}
/**

View file

@ -73,8 +73,4 @@ export class DataViewEditorPlugin
},
};
}
public stop() {
return {};
}
}

View file

@ -55,8 +55,4 @@ export class IndexPatternFieldEditorPlugin
DeleteRuntimeFieldProvider: getDeleteFieldProvider(openDeleteModal),
};
}
public stop() {
return {};
}
}

View file

@ -22,8 +22,4 @@ export class RuntimeFieldsPlugin
public start(core: CoreStart, plugins: StartPlugins) {
return {};
}
public stop() {
return {};
}
}

View file

@ -348,7 +348,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
public stop() {
this.queryService.stop();
licenseService.stop();
return this.contract.getStopContract();
this.contract.getStopContract();
}
private lazyHelpersForRoutes() {