Skip to content

Commit

Permalink
Correctly type ILM's optional dependencies as optional (elastic#63255)
Browse files Browse the repository at this point in the history
And guard against their absence.
  • Loading branch information
cjcenizal committed Apr 10, 2020
1 parent 4a20073 commit 155d677
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import {

import { defaultColdPhase, defaultWarmPhase, defaultHotPhase } from '../store/defaults';

export let trackUiMetric: (metricType: UiStatsMetricType, eventName: string) => void;
export let trackUiMetric = (metricType: UiStatsMetricType, eventName: string) => {};

export function init(usageCollection: UsageCollectionSetup): void {
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
export function init(usageCollection?: UsageCollectionSetup): void {
if (usageCollection) {
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
}
}

export function getUiMetricsForPhases(phases: any): any {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_lifecycle_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ManagementSetup } from '../../../../src/plugins/management/public';
import { IndexManagementPluginSetup } from '../../index_management/public';

export interface PluginsDependencies {
usageCollection: UsageCollectionSetup;
usageCollection?: UsageCollectionSetup;
management: ManagementSetup;
indexManagement?: IndexManagementPluginSetup;
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_lifecycle_management/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class IndexLifecycleManagementServerPlugin implements Plugin<void, void,
});

if (config.ui.enabled) {
if (indexManagement.indexDataEnricher) {
if (indexManagement && indexManagement.indexDataEnricher) {
indexManagement.indexDataEnricher.add(indexLifecycleDataEnricher);
}
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_lifecycle_management/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isEsError } from './lib/is_es_error';

export interface Dependencies {
licensing: LicensingPluginSetup;
indexManagement: IndexManagementPluginSetup;
indexManagement?: IndexManagementPluginSetup;
}

export interface RouteDependencies {
Expand Down

0 comments on commit 155d677

Please sign in to comment.