Skip to content

Commit

Permalink
[Visualizations] fix types on TS upgrade (#16)
Browse files Browse the repository at this point in the history
* [Visualizations] fix types on TS upgrade

* PR comment
  • Loading branch information
stratoula authored Aug 7, 2023
1 parent a53bb8b commit f33aa04
Show file tree
Hide file tree
Showing 4 changed files with 7 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
9 changes: 3 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,18 @@ 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 && { ...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 && { ...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 f33aa04

Please sign in to comment.