Skip to content

Commit

Permalink
change some types
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Apr 29, 2019
1 parent 1ce9f30 commit 1e24e4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '../embeddables';
import { ViewMode } from '../types';
import { IContainer } from './i_container';
import { IEmbeddable } from '../embeddables/i_embeddable';

export interface PanelState<E extends { [key: string]: unknown } = { [key: string]: unknown }> {
savedObjectId?: string;
Expand Down Expand Up @@ -63,7 +64,7 @@ export abstract class Container<
> extends Embeddable<I, O> implements IContainer<I, O> {
public readonly isContainer: boolean = true;
protected readonly children: {
[key: string]: Embeddable<any, any> | ErrorEmbeddable;
[key: string]: IEmbeddable<any, any> | ErrorEmbeddable;
} = {};
public readonly embeddableFactories: EmbeddableFactoryRegistry;

Expand Down Expand Up @@ -111,11 +112,11 @@ export abstract class Container<
public async addNewEmbeddable<
EEI extends EmbeddableInput = EmbeddableInput,
EEO extends EmbeddableOutput = EmbeddableOutput,
E extends Embeddable<EEI, EEO> = Embeddable<EEI, EEO>
E extends IEmbeddable<EEI, EEO> = IEmbeddable<EEI, EEO>
>(type: string, explicitInput: Partial<EEI>): Promise<E | ErrorEmbeddable> {
const factory = this.embeddableFactories.getFactoryByName(type) as EmbeddableFactory<
EEI,
any,
EEO,
E
>;
const panelState = this.createNewPanelState<EEI>(factory, explicitInput);
Expand All @@ -135,11 +136,11 @@ export abstract class Container<

public async addSavedObjectEmbeddable<
EEI extends EmbeddableInput = EmbeddableInput,
E extends Embeddable<EEI> = Embeddable<EEI>
E extends IEmbeddable<EEI, EmbeddableOutput> = IEmbeddable<EEI, EmbeddableOutput>
>(type: string, savedObjectId: string): Promise<E | ErrorEmbeddable> {
const factory = this.embeddableFactories.getFactoryByName(type) as EmbeddableFactory<
EEI,
any,
EmbeddableOutput,
E
>;
const panelState = this.createNewPanelState<EEI>(factory);
Expand Down Expand Up @@ -308,7 +309,7 @@ export abstract class Container<

private createNewExplicitEmbeddableInput<
EEI extends EmbeddableInput = EmbeddableInput,
E extends Embeddable<EEI> = Embeddable<EEI>
E extends IEmbeddable<EEI, EmbeddableOutput> = IEmbeddable<EEI, EmbeddableOutput>
>(id: string, factory: EmbeddableFactory<EEI, any, E>, partial: Partial<EEI> = {}) {
const inheritedInput = this.getInheritedInput(id) as { [key: string]: unknown };
const defaults = factory.getDefaultInputParameters() as { [key: string]: unknown };
Expand Down Expand Up @@ -342,7 +343,7 @@ export abstract class Container<

private async onPanelAdded(panel: PanelState) {
const factory = this.embeddableFactories.getFactoryByName(panel.type);
const embeddable = await factory.create<Embeddable>(
const embeddable: IEmbeddable<EmbeddableInput, EmbeddableOutput> = await factory.create(
this.getInputForChild(panel.embeddableId),
this
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export interface IContainer<
addNewEmbeddable<
EEI extends EmbeddableInput = EmbeddableInput,
EEO extends EmbeddableOutput = EmbeddableOutput,
E extends Embeddable<EEI, EEO> = Embeddable<EEI, EEO>
E extends IEmbeddable<EEI, EEO> = IEmbeddable<EEI, EEO>
>(
type: string,
explicitInput: Partial<EEI>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Embeddable, EmbeddableInput, EmbeddableOutput } from './embeddable';
import { ErrorEmbeddable } from './error_embeddable';
import { Container, ContainerOutput } from '../containers';
import { ContainerInput } from '../containers/i_container';
import { IEmbeddable } from './i_embeddable';

export interface EmbeddableInstanceConfiguration {
id: string;
Expand All @@ -49,7 +50,7 @@ export interface OutputSpec {
export abstract class EmbeddableFactory<
I extends EmbeddableInput = EmbeddableInput,
O extends EmbeddableOutput = EmbeddableOutput,
E extends Embeddable<I, O> = Embeddable<I, O>,
E extends IEmbeddable<I, O> = IEmbeddable<I, O>,
T extends SavedObjectAttributes = SavedObjectAttributes
> {
public readonly name: string;
Expand Down

0 comments on commit 1e24e4b

Please sign in to comment.