Skip to content

Commit

Permalink
[Visualizations] fix types on TS upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Aug 7, 2023
1 parent d398d24 commit 920e54a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/plugins/charts/common/static/components/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const LabelRotation = Object.freeze({
Horizontal: 0,
Vertical: 90,
Angled: 75,
VerticalRotation: 270,
});
export type LabelRotation = $Values<typeof LabelRotation>;

Expand Down
11 changes: 5 additions & 6 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainOutput>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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]
);
Expand Down

0 comments on commit 920e54a

Please sign in to comment.