diff --git a/src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt b/src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt index 15d3eb058bcf3a..b04178ec71c6f3 100644 --- a/src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt +++ b/src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt @@ -61,9 +61,6 @@ x-pack/plugins/lens/public/datatable_visualization/expression.tsx kibana-app x-pack/plugins/lens/public/datatable_visualization/index.ts kibana-app x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx kibana-app x-pack/plugins/lens/public/datatable_visualization/visualization.tsx kibana-app -x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx kibana-app -x-pack/plugins/lens/public/debounced_component/debounced_component.tsx kibana-app -x-pack/plugins/lens/public/debounced_component/index.ts kibana-app x-pack/plugins/lens/public/drag_drop/drag_drop.test.tsx kibana-app x-pack/plugins/lens/public/drag_drop/drag_drop.tsx kibana-app x-pack/plugins/lens/public/drag_drop/index.ts kibana-app diff --git a/src/plugins/chart_expressions/expression_legacy_metric/public/__stories__/metric_renderer.stories.tsx b/src/plugins/chart_expressions/expression_legacy_metric/public/__stories__/metric_renderer.stories.tsx index 46bc90eda35c96..72e52ef303f4c2 100644 --- a/src/plugins/chart_expressions/expression_legacy_metric/public/__stories__/metric_renderer.stories.tsx +++ b/src/plugins/chart_expressions/expression_legacy_metric/public/__stories__/metric_renderer.stories.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { storiesOf } from '@storybook/react'; import { from } from 'rxjs'; import { ExpressionValueVisDimension } from '@kbn/visualizations-plugin/common'; -import { Datatable, DatatableColumn } from '@kbn/expressions-plugin/common'; +import { Datatable, DatatableColumn, TextAlignment } from '@kbn/expressions-plugin/common'; import { Render } from '@kbn/presentation-util-plugin/public/__stories__'; import { ColorMode, CustomPaletteState } from '@kbn/charts-plugin/common'; import { getFormatService } from '../__mocks__/format_service'; @@ -209,8 +209,11 @@ storiesOf('renderers/visMetric', module) }, labels: { show: false, - // @ts-expect-error upgrade typescript v4.9.5 - style: { spec: { fontSize: '60px', align: 'left' }, type: 'style', css: '' }, + style: { + spec: { fontSize: '60px', textAlign: TextAlignment.LEFT }, + type: 'style', + css: '', + }, position: LabelPosition.TOP, }, }, diff --git a/src/plugins/chart_expressions/expression_legacy_metric/public/components/with_auto_scale.tsx b/src/plugins/chart_expressions/expression_legacy_metric/public/components/with_auto_scale.tsx index f0d21374588f70..36093abaddf5a4 100644 --- a/src/plugins/chart_expressions/expression_legacy_metric/public/components/with_auto_scale.tsx +++ b/src/plugins/chart_expressions/expression_legacy_metric/public/components/with_auto_scale.tsx @@ -63,10 +63,13 @@ function hasAutoscaleProps(props: T): props is T & AutoScaleProps { return false; } -function getWrappedComponentProps(props: T) { +function getWrappedComponentProps(props: T): T { if (hasAutoscaleProps(props)) { - const { autoScaleParams, renderComplete, ...rest } = props; - return rest; + return { + ...props, + autoScaleParams: undefined, + renderComplete: undefined, + }; } return props; @@ -132,8 +135,7 @@ export function withAutoScale(WrappedComponent: ComponentType) { : {}), }} > - {/* @ts-expect-error upgrade typescript v4.9.5*/} - + ); diff --git a/src/plugins/expressions/common/execution/execution_contract.ts b/src/plugins/expressions/common/execution/execution_contract.ts index ad5172356fe4e9..50dda43661367f 100644 --- a/src/plugins/expressions/common/execution/execution_contract.ts +++ b/src/plugins/expressions/common/execution/execution_contract.ts @@ -17,17 +17,19 @@ import { ExpressionAstExpression } from '../ast'; * `ExecutionContract` is a wrapper around `Execution` class. It provides the * same functionality but does not expose Expressions plugin internals. */ -export class ExecutionContract { +export class ExecutionContract< + Input = unknown, + Output = unknown, + InspectorAdapters extends Adapters = object +> { public get isPending(): boolean { const { state, result } = this.execution.state.get(); const finished = state === 'error' || (state === 'result' && !result?.partial); return !finished; } - // @ts-expect-error upgrade typescript v4.9.5 protected readonly execution: Execution; - // @ts-expect-error upgrade typescript v4.9.5 constructor(execution: Execution) { this.execution = execution; } @@ -82,6 +84,5 @@ export class ExecutionContract this.execution.inspectorAdapters; } diff --git a/src/plugins/vis_types/table/public/components/table_vis_basic.test.tsx b/src/plugins/vis_types/table/public/components/table_vis_basic.test.tsx index 22311712caab04..66d71693cdcbd4 100644 --- a/src/plugins/vis_types/table/public/components/table_vis_basic.test.tsx +++ b/src/plugins/vis_types/table/public/components/table_vis_basic.test.tsx @@ -13,6 +13,7 @@ import { FormattedColumn, TableVisConfig, TableVisUiState } from '../types'; import { DatatableColumn } from '@kbn/expressions-plugin/common'; import { createTableVisCell } from './table_vis_cell'; import { createGridColumns } from './table_vis_columns'; +import { EuiDataGridProps } from '@elastic/eui'; jest.mock('./table_vis_columns', () => ({ createGridColumns: jest.fn(() => []), @@ -107,8 +108,8 @@ describe('TableVisBasic', () => { undefined ); - // @ts-expect-error upgrade typescript v4.9.5 - const { onSort } = comp.find('EuiDataGrid').prop('sorting'); + const { onSort } = comp.find('EuiDataGrid').prop('sorting')!; + // sort the first column onSort([{ id: 'first', direction: 'asc' }]); expect(uiStateProps.setSort).toHaveBeenCalledWith({ columnIndex: 0, direction: 'asc' }); diff --git a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile.ts b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile.ts index f18de61707886d..1cc36538798029 100644 --- a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile.ts +++ b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile.ts @@ -49,19 +49,20 @@ export const convertToPercentileColumn = ( return null; } const commonColumnParams = createColumn(series, metric, field, { reducedTimeRange, timeShift }); + const meta: PercentileColumn['meta'] = + index !== undefined + ? { + reference: `${metric.id}.${index}`, + ...commonColumnParams.meta, + } + : commonColumnParams.meta; + return { operationType: 'percentile', sourceField: field.name, ...commonColumnParams, params: { ...params, ...getFormat(series) }, - // @ts-expect-error upgrade typescript v4.9.5 - meta: - index !== undefined - ? { - reference: `${metric.id}.${index}`, - ...commonColumnParams.meta, - } - : commonColumnParams.meta, + meta, }; }; diff --git a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile_rank.ts b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile_rank.ts index 54ac8e11dd7677..27f9c021c56cae 100644 --- a/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile_rank.ts +++ b/src/plugins/vis_types/timeseries/public/convert_to_lens/lib/convert/percentile_rank.ts @@ -19,6 +19,7 @@ import { Column, PercentileRanksColumnWithExtendedMeta, CommonColumnConverterArgs, + PercentileColumn, } from './types'; export const isPercentileRanksColumnWithMeta = ( @@ -56,19 +57,19 @@ export const convertToPercentileRankColumn = ( } const commonColumnParams = createColumn(series, metric, field, { reducedTimeRange, timeShift }); + const meta: PercentileColumn['meta'] = + index !== undefined + ? { + reference: `${metric.id}.${index}`, + ...commonColumnParams.meta, + } + : commonColumnParams.meta; return { operationType: 'percentile_rank', sourceField: field.name, ...commonColumnParams, params: { ...params, ...getFormat(series) }, - // @ts-expect-error upgrade typescript v4.9.5 - meta: - index !== undefined - ? { - reference: `${metric.id}.${index}`, - ...commonColumnParams.meta, - } - : commonColumnParams.meta, + meta, }; }; diff --git a/src/plugins/visualizations/public/vis.ts b/src/plugins/visualizations/public/vis.ts index b02daa7c50fd0e..89e7282c4449e0 100644 --- a/src/plugins/visualizations/public/vis.ts +++ b/src/plugins/visualizations/public/vis.ts @@ -57,7 +57,7 @@ const getSearchSource = async (inputSearchSource: ISearchSource, savedSearchId?: type PartialVisState = Assign }>; -export class Vis { +export class Vis { public readonly type: BaseVisType; public readonly id?: string; public title: string = ''; @@ -69,7 +69,6 @@ export class Vis { constructor(visType: string, visState: SerializedVis = {} as any) { this.type = this.getType(visType); - // @ts-expect-error upgrade typescript v4.9.5 this.params = this.getParams(visState.params); this.uiState = new PersistedState(visState.uiState); this.id = visState.id; @@ -192,7 +191,6 @@ export class Vis { title: this.title, description: this.description, type: this.type.name, - // @ts-expect-error upgrade typescript v4.9.5 params: cloneDeep(this.params), uiState: this.uiState.toJSON(), data: { diff --git a/src/plugins/visualizations/public/vis_async.ts b/src/plugins/visualizations/public/vis_async.ts index 8f2f92cc36db71..4e295596b1611f 100644 --- a/src/plugins/visualizations/public/vis_async.ts +++ b/src/plugins/visualizations/public/vis_async.ts @@ -9,7 +9,7 @@ import type { SerializedVis } from './vis'; import type { VisParams } from '../common'; -export const createVisAsync = async ( +export const createVisAsync = async ( visType: string, visState: SerializedVis = {} as any ) => { @@ -20,7 +20,6 @@ export const createVisAsync = async ( const { Vis } = await import('./vis'); const vis = new Vis(visType, visState); - // @ts-expect-error upgrade typescript v4.9.5 await vis.setState(visState); return vis; }; diff --git a/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx b/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx deleted file mode 100644 index d52eb3c5780591..00000000000000 --- a/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; -import { debouncedComponent } from './debounced_component'; -import { act } from 'react-dom/test-utils'; - -describe('debouncedComponent', () => { - test('immediately renders', () => { - const TestComponent = debouncedComponent(({ title }: { title: string }) => { - return

{title}

; - }); - expect(mount().html()).toMatchInlineSnapshot(`"

hoi

"`); - }); - - test('debounces changes', async () => { - const TestComponent = debouncedComponent(({ title }: { title: string }) => { - return

{title}

; - }, 1); - const component = mount(); - component.setProps({ title: 'yall' }); - expect(component.text()).toEqual('there'); - await act(async () => { - await new Promise((r) => setTimeout(r, 10)); - }); - expect(component.text()).toEqual('yall'); - }); -}); diff --git a/x-pack/plugins/lens/public/debounced_component/debounced_component.tsx b/x-pack/plugins/lens/public/debounced_component/debounced_component.tsx deleted file mode 100644 index 53f1f1722ab3a1..00000000000000 --- a/x-pack/plugins/lens/public/debounced_component/debounced_component.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { useState, useMemo, useEffect, memo, FunctionComponent } from 'react'; -import { debounce } from 'lodash'; - -/** - * debouncedComponent wraps the specified React component, returning a component which - * only renders once there is a pause in props changes for at least `delay` milliseconds. - * During the debounce phase, it will return the previously rendered value. - */ -export function debouncedComponent(component: FunctionComponent, delay = 256) { - const MemoizedComponent = memo(component) as unknown as FunctionComponent; - - return (props: TProps) => { - const [cachedProps, setCachedProps] = useState(props); - const debouncePropsChange = useMemo(() => debounce(setCachedProps, delay), [setCachedProps]); - - // cancel debounced prop change if component has been unmounted in the meantime - useEffect(() => () => debouncePropsChange.cancel(), [debouncePropsChange]); - debouncePropsChange(props); - - // @ts-expect-error upgrade typescript v4.9.5 - return React.createElement(MemoizedComponent, cachedProps); - }; -} diff --git a/x-pack/plugins/lens/public/debounced_component/index.ts b/x-pack/plugins/lens/public/debounced_component/index.ts deleted file mode 100644 index 68d247b5e3b3f9..00000000000000 --- a/x-pack/plugins/lens/public/debounced_component/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export * from './debounced_component'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index 930dd4940171c8..af3bdb62ab032d 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -18,11 +18,6 @@ import { } from '../../../mocks'; import { mockDataPlugin, mountWithProvider } from '../../../mocks'; -jest.mock('../../../debounced_component', () => { - return { - debouncedComponent: (fn: unknown) => fn, - }; -}); import { WorkspacePanel } from './workspace_panel'; import { ReactWrapper } from 'enzyme'; diff --git a/x-pack/plugins/lens/public/state_management/lens_slice.ts b/x-pack/plugins/lens/public/state_management/lens_slice.ts index 284db90d69551b..d0c6e0f38b20dd 100644 --- a/x-pack/plugins/lens/public/state_management/lens_slice.ts +++ b/x-pack/plugins/lens/public/state_management/lens_slice.ts @@ -1005,15 +1005,13 @@ export const makeLensReducer = (storeDeps: LensStoreDeps) => { activeVisualization.removeLayer && state.visualization.state ) { - const updater = layerIds.reduce( + const updater = layerIds.reduce( (acc, layerId) => - // @ts-expect-error upgrade typescript v4.9.5 activeVisualization.removeLayer ? activeVisualization.removeLayer(acc, layerId) : acc, state.visualization.state ); state.visualization.state = - // @ts-expect-error upgrade typescript v4.9.5 typeof updater === 'function' ? updater(current(state.visualization.state)) : updater; } diff --git a/x-pack/plugins/lens/server/migrations/common_migrations.ts b/x-pack/plugins/lens/server/migrations/common_migrations.ts index 0b7962280559e5..f6a683afc22973 100644 --- a/x-pack/plugins/lens/server/migrations/common_migrations.ts +++ b/x-pack/plugins/lens/server/migrations/common_migrations.ts @@ -502,7 +502,11 @@ export const commonMigratePartitionChartGroups = ( }> ): LensDocShape850<{ shape: string; - layers: Array<{ primaryGroups?: string[]; secondaryGroups?: string[] }>; + layers: Array<{ + primaryGroups?: string[]; + secondaryGroups?: string[]; + [key: string]: unknown; // unknown carryover key/values + }>; }> => { if ( attributes.state.visualization?.layers && @@ -514,7 +518,6 @@ export const commonMigratePartitionChartGroups = ( ...attributes.state, visualization: { ...attributes.state.visualization, - // @ts-expect-error upgrade typescript v4.9.5 layers: attributes.state.visualization.layers.map((l) => { const groups = l.groups;