From 8a283de3c5884e21c245b1136f39132eeb2d976f Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Fri, 10 Apr 2020 12:05:20 -0700 Subject: [PATCH] Correctly type ILM's optional dependencies as optional (#63255) And guard against their absence. --- .../public/application/services/ui_metric.ts | 8 +++++--- x-pack/plugins/index_lifecycle_management/public/types.ts | 2 +- .../plugins/index_lifecycle_management/server/plugin.ts | 2 +- x-pack/plugins/index_lifecycle_management/server/types.ts | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts index ca6c0b44d5804..ca987441c7ce9 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts @@ -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 { diff --git a/x-pack/plugins/index_lifecycle_management/public/types.ts b/x-pack/plugins/index_lifecycle_management/public/types.ts index f9e0abae56cb4..178884a7ee679 100644 --- a/x-pack/plugins/index_lifecycle_management/public/types.ts +++ b/x-pack/plugins/index_lifecycle_management/public/types.ts @@ -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; } diff --git a/x-pack/plugins/index_lifecycle_management/server/plugin.ts b/x-pack/plugins/index_lifecycle_management/server/plugin.ts index 48c50f9a48ee5..faeac67f62a21 100644 --- a/x-pack/plugins/index_lifecycle_management/server/plugin.ts +++ b/x-pack/plugins/index_lifecycle_management/server/plugin.ts @@ -75,7 +75,7 @@ export class IndexLifecycleManagementServerPlugin implements Plugin