Skip to content

Commit

Permalink
Correctly type ILM's optional dependencies as optional and guard agai…
Browse files Browse the repository at this point in the history
…nst their absence.
  • Loading branch information
cjcenizal committed Apr 10, 2020
1 parent 36acb37 commit 24762dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ import { defaultColdPhase, defaultWarmPhase, defaultHotPhase } from '../store/de

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

export function init(usageCollection: UsageCollectionSetup): void {
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
export function init(usageCollection: UsageCollectionSetup | undefined): void {
if (usageCollection) {
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
} else {
trackUiMetric = (metricType, eventName) => {};
}
}

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 24762dd

Please sign in to comment.