From 920e54a727585bd5f502c67c26ab942354294375 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 7 Aug 2023 13:00:34 +0300 Subject: [PATCH 1/2] [Visualizations] fix types on TS upgrade --- .../charts/common/static/components/collections.ts | 1 + src/plugins/expressions/common/execution/execution.ts | 11 +++++------ .../heatmap/public/editor/components/labels_panel.tsx | 2 -- .../components/options/metrics_axes/label_options.tsx | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/plugins/charts/common/static/components/collections.ts b/src/plugins/charts/common/static/components/collections.ts index 1f138ab9f7b0eb..acb11c647fead9 100644 --- a/src/plugins/charts/common/static/components/collections.ts +++ b/src/plugins/charts/common/static/components/collections.ts @@ -20,6 +20,7 @@ export const LabelRotation = Object.freeze({ Horizontal: 0, Vertical: 90, Angled: 75, + VerticalRotation: 270, }); export type LabelRotation = $Values; diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts index 1e010be4e95577..246109499bd5c9 100644 --- a/src/plugins/expressions/common/execution/execution.ts +++ b/src/plugins/expressions/common/execution/execution.ts @@ -420,21 +420,20 @@ export class Execution< : of(resolvedArgs); return args$.pipe( - // @ts-expect-error upgrade to ts v4.7.4 - tap((args) => this.execution.params.debug && Object.assign(head.debug, { args })), + tap((args) => this.execution.params.debug && Object.assign(head.debug ?? {}, { args })), switchMap((args) => this.invokeFunction(fn, input, args)), this.execution.params.partial ? identity : last(), switchMap((output) => (getType(output) === 'error' ? throwError(output) : of(output))), - // @ts-expect-error upgrade to ts v4.7.4 - tap((output) => this.execution.params.debug && Object.assign(head.debug, { output })), + tap( + (output) => this.execution.params.debug && Object.assign(head.debug ?? {}, { output }) + ), switchMap((output) => this.invokeChain(tail, output)), catchError((rawError) => { const error = createError(rawError); error.error.message = `[${fnName}] > ${error.error.message}`; if (this.execution.params.debug) { - // @ts-expect-error upgrade to ts v4.7.4 - Object.assign(head.debug, { error, rawError, success: false }); + Object.assign(head.debug ?? {}, { error, rawError, success: false }); } return of(error); diff --git a/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx b/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx index 59e4a20c8aac1a..0b16e538fb4819 100644 --- a/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx +++ b/src/plugins/vis_types/heatmap/public/editor/components/labels_panel.tsx @@ -25,7 +25,6 @@ interface LabelsPanelProps { } function LabelsPanel({ valueAxis, setValue, isNewLibrary }: LabelsPanelProps) { - // @ts-expect-error ts upgrade v4.7.4 const rotateLabels = valueAxis.labels.rotate === VERTICAL_ROTATION; const setValueAxisLabels = useCallback( @@ -44,7 +43,6 @@ function LabelsPanel({ valueAxis, setValue, isNewLibrary }: LabelsPanelProps) { const setRotateLabels = useCallback( (paramName: 'rotate', value: boolean) => - // @ts-expect-error ts upgrade v4.7.4 setValueAxisLabels(paramName, value ? VERTICAL_ROTATION : 0), [setValueAxisLabels] ); diff --git a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/label_options.tsx b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/label_options.tsx index fa5d9547e8157b..3310df7259df66 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/label_options.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/label_options.tsx @@ -13,7 +13,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { SelectOption, SwitchOption } from '@kbn/vis-default-editor-plugin/public'; -import { Labels } from '@kbn/charts-plugin/public'; +import type { LabelRotation, Labels } from '@kbn/charts-plugin/public'; import { TruncateLabelsOption } from '../../common'; import { getRotateOptions } from '../../../collections'; @@ -34,8 +34,8 @@ function LabelOptions({ }: LabelOptionsProps) { const setAxisLabelRotate = useCallback( (paramName: 'rotate', value: Labels['rotate']) => { - // @ts-expect-error ts upgrade v4.7.4 - setAxisLabel(paramName, Number(value)); + const rotation = Number(value) as LabelRotation; + setAxisLabel(paramName, rotation); }, [setAxisLabel] ); From c8c23fc0ca63c48c24a2fd2d995af80a3b81cd0d Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 7 Aug 2023 17:45:05 +0300 Subject: [PATCH 2/2] PR comment --- src/plugins/expressions/common/execution/execution.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts index 246109499bd5c9..7b4e02df0a3d8a 100644 --- a/src/plugins/expressions/common/execution/execution.ts +++ b/src/plugins/expressions/common/execution/execution.ts @@ -420,13 +420,11 @@ export class Execution< : of(resolvedArgs); return args$.pipe( - tap((args) => this.execution.params.debug && Object.assign(head.debug ?? {}, { args })), + tap((args) => this.execution.params.debug && { ...head.debug, args }), switchMap((args) => this.invokeFunction(fn, input, args)), this.execution.params.partial ? identity : last(), switchMap((output) => (getType(output) === 'error' ? throwError(output) : of(output))), - tap( - (output) => this.execution.params.debug && Object.assign(head.debug ?? {}, { output }) - ), + tap((output) => this.execution.params.debug && { ...head.debug, output }), switchMap((output) => this.invokeChain(tail, output)), catchError((rawError) => { const error = createError(rawError);