Skip to content

Commit

Permalink
Narrow type of PluginDeps to an object (#40846)
Browse files Browse the repository at this point in the history
* Narrow type of PluginDeps to an object

* re-generate docs
  • Loading branch information
mshustov authored Jul 23, 2019
1 parent 3467c45 commit 4e73b18
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The interface that should be returned by a `PluginInitializer`<!-- -->.
<b>Signature:</b>

```typescript
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}>
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends object = object, TPluginsStart extends object = object>
```

## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The `plugin` export at the root of a plugin's `public` directory should conform
<b>Signature:</b>

```typescript
export declare type PluginInitializer<TSetup, TStart, TPluginsSetup extends Record<string, any> = {}, TPluginsStart extends Record<string, any> = {}> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
export declare type PluginInitializer<TSetup, TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The interface that should be returned by a `PluginInitializer`<!-- -->.
<b>Signature:</b>

```typescript
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}>
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends object = object, TPluginsStart extends object = object>
```

## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The `plugin` export at the root of a plugin's `server` directory should conform
<b>Signature:</b>

```typescript
export declare type PluginInitializer<TSetup, TStart, TPluginsSetup extends Record<PluginName, unknown> = {}, TPluginsStart extends Record<PluginName, unknown> = {}> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
export declare type PluginInitializer<TSetup, TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
```
14 changes: 7 additions & 7 deletions src/core/public/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { DiscoveredPlugin, PluginName } from '../../server';
import { DiscoveredPlugin } from '../../server';
import { PluginInitializerContext } from './plugin_context';
import { loadPluginBundle } from './plugin_loader';
import { CoreStart, CoreSetup } from '..';
Expand All @@ -30,8 +30,8 @@ import { CoreStart, CoreSetup } from '..';
export interface Plugin<
TSetup = void,
TStart = void,
TPluginsSetup extends {} = {},
TPluginsStart extends {} = {}
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> {
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
Expand All @@ -47,8 +47,8 @@ export interface Plugin<
export type PluginInitializer<
TSetup,
TStart,
TPluginsSetup extends Record<string, any> = {},
TPluginsStart extends Record<string, any> = {}
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

/**
Expand All @@ -60,8 +60,8 @@ export type PluginInitializer<
export class PluginWrapper<
TSetup = unknown,
TStart = unknown,
TPluginsSetup extends Record<PluginName, any> = Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, any> = Record<PluginName, unknown>
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> {
public readonly name: DiscoveredPlugin['id'];
public readonly configPath: DiscoveredPlugin['configPath'];
Expand Down
10 changes: 5 additions & 5 deletions src/core/public/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { omit } from 'lodash';

import { DiscoveredPlugin, PluginName } from '../../server';
import { DiscoveredPlugin } from '../../server';
import { CoreContext } from '../core_system';
import { PluginWrapper } from './plugin';
import { PluginsServiceSetupDeps, PluginsServiceStartDeps } from './plugins_service';
Expand Down Expand Up @@ -61,8 +61,8 @@ export function createPluginInitializerContext(
export function createPluginSetupContext<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, unknown>
TPluginsSetup extends object,
TPluginsStart extends object
>(
coreContext: CoreContext,
deps: PluginsServiceSetupDeps,
Expand All @@ -89,8 +89,8 @@ export function createPluginSetupContext<
export function createPluginStartContext<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, unknown>
TPluginsSetup extends object,
TPluginsStart extends object
>(
coreContext: CoreContext,
deps: PluginsServiceStartDeps,
Expand Down
8 changes: 4 additions & 4 deletions src/core/public/plugins/plugin_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export const LOAD_TIMEOUT = 120 * 1000; // 2 minutes
export const loadPluginBundle: LoadPluginBundle = <
TSetup,
TStart,
TPluginsSetup extends Record<string, unknown>,
TPluginsStart extends Record<string, unknown>
TPluginsSetup extends object,
TPluginsStart extends object
>(
addBasePath: (path: string) => string,
pluginName: PluginName,
Expand Down Expand Up @@ -125,8 +125,8 @@ export const loadPluginBundle: LoadPluginBundle = <
export type LoadPluginBundle = <
TSetup,
TStart,
TPluginsSetup extends Record<string, unknown>,
TPluginsStart extends Record<string, unknown>
TPluginsSetup extends object,
TPluginsStart extends object
>(
addBasePath: (path: string) => string,
pluginName: PluginName,
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export interface OverlayStart {
}

// @public
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}> {
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends object = object, TPluginsStart extends object = object> {
// (undocumented)
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
// (undocumented)
Expand All @@ -485,7 +485,7 @@ export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} =
}

// @public
export type PluginInitializer<TSetup, TStart, TPluginsSetup extends Record<string, any> = {}, TPluginsStart extends Record<string, any> = {}> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
export type PluginInitializer<TSetup, TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

// @public
export interface PluginInitializerContext {
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export interface DiscoveredPluginInternal extends DiscoveredPlugin {
export interface Plugin<
TSetup = void,
TStart = void,
TPluginsSetup extends {} = {},
TPluginsStart extends {} = {}
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> {
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
Expand All @@ -155,8 +155,8 @@ export interface Plugin<
export type PluginInitializer<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown> = {},
TPluginsStart extends Record<PluginName, unknown> = {}
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

/**
Expand All @@ -168,8 +168,8 @@ export type PluginInitializer<
export class PluginWrapper<
TSetup = unknown,
TStart = unknown,
TPluginsSetup extends Record<PluginName, unknown> = Record<PluginName, unknown>,
TPluginsStart extends Record<PluginName, unknown> = Record<PluginName, unknown>
TPluginsSetup extends object = object,
TPluginsStart extends object = object
> {
public readonly name: PluginManifest['id'];
public readonly configPath: PluginManifest['configPath'];
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export interface OnPreAuthToolkit {
}

// @public
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}> {
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends object = object, TPluginsStart extends object = object> {
// (undocumented)
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
// (undocumented)
Expand All @@ -341,7 +341,7 @@ export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} =
}

// @public
export type PluginInitializer<TSetup, TStart, TPluginsSetup extends Record<PluginName, unknown> = {}, TPluginsStart extends Record<PluginName, unknown> = {}> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;
export type PluginInitializer<TSetup, TStart, TPluginsSetup extends object = object, TPluginsStart extends object = object> = (core: PluginInitializerContext) => Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

// @public
export interface PluginInitializerContext<ConfigSchema = unknown> {
Expand Down

0 comments on commit 4e73b18

Please sign in to comment.