From bdd57b64fe19683c481f673d6f1571f91379e730 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 1 Oct 2024 11:40:11 +0200 Subject: [PATCH] [React@18] Upgrade @types to React 18 (#194144) ## Summary Part of https://github.com/elastic/kibana/issues/138222 This PR finilizes the breaking type fixes that are needed for upgrade to React@18. Most of the remaining issues are muted with "@ts-expect-error" are tricky or could be runtime bugs that need to be looked at. **Since the types changes are backward compatible (except the new APIs) we can upgrade to @types/react@18 now so that we "save" the progress and all the code in Kibana from now on is written in compatbile for react@18 way from types perspective.** --- package.json | 8 +++--- .../src/toasts/global_toast_list.tsx | 1 - .../core-overlays-browser/src/flyout.ts | 5 +++- packages/kbn-eslint-config/.eslintrc.js | 7 +++++ packages/kbn-esql-editor/src/esql_editor.tsx | 4 +-- .../src/components/resizable_container.tsx | 4 +-- .../src/components/as_flyout/index.tsx | 6 +++-- .../src/components/as_inline/index.tsx | 6 +++-- .../field_row/description/description.tsx | 1 - .../custom_toolbar/render_custom_toolbar.tsx | 9 ++----- .../src/components/data_table.test.tsx | 4 +-- .../components/heatmap_component.test.tsx | 2 +- .../public/components/metric_vis.test.tsx | 2 ++ .../partition_vis_component.test.tsx | 2 +- .../data_types/logs/service_name_cell.tsx | 2 +- .../use_additional_cell_actions.test.tsx | 2 +- .../fields/card_radio_group_field.tsx | 4 +-- .../floating_actions/floating_actions.tsx | 3 +-- .../public/context_menu/open_context_menu.tsx | 1 + .../document_entry_editor.tsx | 5 ++-- .../index.tsx | 8 +++--- .../index_entry_editor.tsx | 14 ++++++---- .../use_knowledge_base_table.tsx | 10 +++++-- .../renderers/host/with_expandable_flyout.tsx | 2 +- .../workpad/hooks/use_refresh_helper.test.tsx | 1 + .../public/routes/workpad/workpad_route.tsx | 2 ++ .../analytics_collection_explorer_table.tsx | 3 +++ .../analytics_collection_overview_table.tsx | 3 +++ .../connector_detail/connector_detail.tsx | 4 ++- .../ml_inference/pipeline_select_option.tsx | 1 + .../hooks/use_fetch_agents_data.tsx | 1 + .../default_to_data_nodes_notice.tsx | 5 +++- .../components/no_tiers_nodes_notice.tsx | 5 +++- .../components/will_fallback_nodes_notice.tsx | 7 ++++- .../searchable_snapshot_field.tsx | 1 + .../definitions/terms/terms.test.tsx | 3 +++ .../alert_actions.tsx | 5 +++- .../custom_hooks/use_create_ad_links.ts | 3 ++- .../waterfall/accordion_waterfall.tsx | 1 + .../shared/links/elastic_docs_link.tsx | 1 + .../apm/public/plugin.ts | 3 +++ .../page_template/page_template.tsx | 12 ++++++--- .../common/links/step_details_link.tsx | 1 + ...managed_policy_create_import_extension.tsx | 2 +- .../components/indices/details_page.tsx | 2 +- .../components/indices/indices_router.tsx | 7 ++++- .../components/start/elasticsearch_start.tsx | 2 +- .../analyzer_panels/index.tsx | 3 ++- .../view/components/blocklist_form.tsx | 12 ++++++--- .../public/upselling/register_upsellings.tsx | 1 + .../process_tree_alerts_filter/index.tsx | 2 +- .../edit_space_content_tab.test.tsx | 2 +- .../edit_space_general_tab.test.tsx | 2 +- .../edit_space/edit_space_roles_tab.test.tsx | 2 +- yarn.lock | 27 +++++++++---------- 55 files changed, 157 insertions(+), 81 deletions(-) diff --git a/package.json b/package.json index aadda3070ecc6..5446bea2c12b2 100644 --- a/package.json +++ b/package.json @@ -90,11 +90,12 @@ "**/hoist-non-react-statics": "^3.3.2", "**/isomorphic-fetch/node-fetch": "^2.6.7", "**/langchain": "^0.2.11", - "**/react-intl/**/@types/react": "^17.0.45", "**/remark-parse/trim": "1.0.1", "**/sharp": "0.32.6", "**/typescript": "5.1.6", "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0", + "@types/react": "~18.2.0", + "@types/react-dom": "~18.2.0", "globby/fast-glob": "^3.2.11" }, "dependencies": { @@ -1607,8 +1608,8 @@ "@types/pngjs": "^3.4.0", "@types/prop-types": "^15.7.5", "@types/rbush": "^3.0.0", - "@types/react": "^17.0.45", - "@types/react-dom": "^17.0.17", + "@types/react": "~18.2.0", + "@types/react-dom": "~18.2.0", "@types/react-grid-layout": "^1.3.2", "@types/react-is": "^17.0.3", "@types/react-recompose": "^0.33.4", @@ -1622,6 +1623,7 @@ "@types/react-window-infinite-loader": "^1.0.9", "@types/redux-actions": "^2.6.1", "@types/resolve": "^1.20.1", + "@types/scheduler": "^0.23.0", "@types/seedrandom": ">=2.0.0 <4.0.0", "@types/selenium-webdriver": "^4.1.26", "@types/semver": "^7.5.8", diff --git a/packages/core/notifications/core-notifications-browser-internal/src/toasts/global_toast_list.tsx b/packages/core/notifications/core-notifications-browser-internal/src/toasts/global_toast_list.tsx index 14339d0d6e9e8..572145c5c8807 100644 --- a/packages/core/notifications/core-notifications-browser-internal/src/toasts/global_toast_list.tsx +++ b/packages/core/notifications/core-notifications-browser-internal/src/toasts/global_toast_list.tsx @@ -31,7 +31,6 @@ interface State { const convertToEui = (toast: ToastWithRichTitle): EuiToast => ({ ...toast, - // @ts-expect-error upgrade typescript v5.1.6 title: toast.title instanceof Function ? : toast.title, text: toast.text instanceof Function ? : toast.text, }); diff --git a/packages/core/overlays/core-overlays-browser/src/flyout.ts b/packages/core/overlays/core-overlays-browser/src/flyout.ts index 6285e90b264c9..68e04de6f6318 100644 --- a/packages/core/overlays/core-overlays-browser/src/flyout.ts +++ b/packages/core/overlays/core-overlays-browser/src/flyout.ts @@ -30,7 +30,10 @@ export interface OverlayFlyoutStart { /** * @public */ -export type OverlayFlyoutOpenOptions = Omit & { +export type OverlayFlyoutOpenOptions = Omit< + EuiFlyoutProps | EuiFlyoutResizableProps, + 'onClose' | 'onResize' +> & { /** * EuiFlyout onClose handler. * If provided the consumer is responsible for calling flyout.close() to close the flyout; diff --git a/packages/kbn-eslint-config/.eslintrc.js b/packages/kbn-eslint-config/.eslintrc.js index 205e5b182e215..f241131cd6273 100644 --- a/packages/kbn-eslint-config/.eslintrc.js +++ b/packages/kbn-eslint-config/.eslintrc.js @@ -171,6 +171,13 @@ module.exports = { from: 'rison-node', to: '@kbn/rison', }, + { + from: 'react-dom/client', + to: 'react-dom', + exact: true, + disallowedMessage: + 'Use `react-dom` instead of `react-dom/client` until upgraded to React 18', + }, ], ], diff --git a/packages/kbn-esql-editor/src/esql_editor.tsx b/packages/kbn-esql-editor/src/esql_editor.tsx index 244abba93a5f9..abdaa577c4bea 100644 --- a/packages/kbn-esql-editor/src/esql_editor.tsx +++ b/packages/kbn-esql-editor/src/esql_editor.tsx @@ -251,7 +251,7 @@ export const ESQLEditor = memo(function ESQLEditor({ const editor1 = useRef(); const containerRef = useRef(null); - const onMouseDownResize = useCallback( + const onMouseDownResize = useCallback( ( mouseDownEvent, firstPanelHeight, @@ -270,7 +270,7 @@ export const ESQLEditor = memo(function ESQLEditor({ [] ); - const onKeyDownResize = useCallback( + const onKeyDownResize = useCallback( ( keyDownEvent, firstPanelHeight, diff --git a/packages/kbn-expandable-flyout/src/components/resizable_container.tsx b/packages/kbn-expandable-flyout/src/components/resizable_container.tsx index c7da40167a7fd..d5e8f2c1b0801 100644 --- a/packages/kbn-expandable-flyout/src/components/resizable_container.tsx +++ b/packages/kbn-expandable-flyout/src/components/resizable_container.tsx @@ -66,10 +66,10 @@ export const ResizableContainer: React.FC = memo( ); const onWidthChange = useCallback( - (newSizes) => + (newSizes: { [key: string]: number }) => dispatch( changeUserSectionWidthsAction({ - ...newSizes, + ...(newSizes as { left: number; right: number }), savedToLocalStorage: true, }) ), diff --git a/packages/kbn-language-documentation/src/components/as_flyout/index.tsx b/packages/kbn-language-documentation/src/components/as_flyout/index.tsx index da6ff14134e1b..1c34a49b5ddde 100644 --- a/packages/kbn-language-documentation/src/components/as_flyout/index.tsx +++ b/packages/kbn-language-documentation/src/components/as_flyout/index.tsx @@ -6,7 +6,7 @@ * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { useCallback, useEffect, useState, useRef, useMemo } from 'react'; +import React, { useCallback, useEffect, useState, useRef, useMemo, ComponentProps } from 'react'; import { EuiFlyout, useEuiTheme, @@ -45,7 +45,9 @@ function DocumentationFlyout({ const scrollTargets = useRef>({}); - const onNavigationChange = useCallback((selectedOptions) => { + const onNavigationChange = useCallback< + NonNullable>['onNavigationChange'] + >((selectedOptions) => { setSelectedSection(selectedOptions.length ? selectedOptions[0].label : undefined); if (selectedOptions.length) { const scrollToElement = scrollTargets.current[selectedOptions[0].label]; diff --git a/packages/kbn-language-documentation/src/components/as_inline/index.tsx b/packages/kbn-language-documentation/src/components/as_inline/index.tsx index 81ffef285d17d..783ab2ac356dc 100644 --- a/packages/kbn-language-documentation/src/components/as_inline/index.tsx +++ b/packages/kbn-language-documentation/src/components/as_inline/index.tsx @@ -6,7 +6,7 @@ * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { useCallback, useState, useRef, useMemo, useEffect } from 'react'; +import React, { useCallback, useState, useRef, useMemo, useEffect, ComponentProps } from 'react'; import { css } from '@emotion/react'; import { useEuiTheme, euiScrollBarStyles, EuiSpacer } from '@elastic/eui'; import { getFilteredGroups } from '../../utils/get_filtered_groups'; @@ -43,7 +43,9 @@ function DocumentationInline({ searchInDescription, height }: DocumentationInlin return getFilteredGroups(searchText, searchInDescription, documentationSections, 1); }, [documentationSections, searchText, searchInDescription]); - const onNavigationChange = useCallback((selectedOptions) => { + const onNavigationChange = useCallback< + NonNullable>['onNavigationChange'] + >((selectedOptions) => { setSelectedSection(selectedOptions.length ? selectedOptions[0].label : undefined); if (selectedOptions.length) { const scrollToElement = scrollTargets.current[selectedOptions[0].label]; diff --git a/packages/kbn-management/settings/components/field_row/description/description.tsx b/packages/kbn-management/settings/components/field_row/description/description.tsx index d843d1303a7a5..cced9d3b7acc0 100644 --- a/packages/kbn-management/settings/components/field_row/description/description.tsx +++ b/packages/kbn-management/settings/components/field_row/description/description.tsx @@ -59,7 +59,6 @@ export const FieldDescription = ({ * Justification for dangerouslySetInnerHTML: * Setting description may contain formatting and links to documentation. */ - /* @ts-expect-error upgrade typescript v5.1.6 */ dangerouslySetInnerHTML={{ __html: content || '' }} // eslint-disable-line react/no-danger /> ); diff --git a/packages/kbn-unified-data-table/src/components/custom_toolbar/render_custom_toolbar.tsx b/packages/kbn-unified-data-table/src/components/custom_toolbar/render_custom_toolbar.tsx index 4785e27ae51b7..d13b8bbc7b03a 100644 --- a/packages/kbn-unified-data-table/src/components/custom_toolbar/render_custom_toolbar.tsx +++ b/packages/kbn-unified-data-table/src/components/custom_toolbar/render_custom_toolbar.tsx @@ -8,18 +8,13 @@ */ import React from 'react'; -import { - EuiDataGridCustomToolbarProps, - EuiDataGridToolBarVisibilityOptions, - EuiFlexGroup, - EuiFlexItem, -} from '@elastic/eui'; +import { EuiDataGridCustomToolbarProps, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import './render_custom_toolbar.scss'; export interface UnifiedDataTableRenderCustomToolbarProps { toolbarProps: EuiDataGridCustomToolbarProps; gridProps: { - additionalControls?: EuiDataGridToolBarVisibilityOptions['additionalControls']; + additionalControls?: React.ReactNode; }; } diff --git a/packages/kbn-unified-data-table/src/components/data_table.test.tsx b/packages/kbn-unified-data-table/src/components/data_table.test.tsx index c797701facdcc..13304d4661cc0 100644 --- a/packages/kbn-unified-data-table/src/components/data_table.test.tsx +++ b/packages/kbn-unified-data-table/src/components/data_table.test.tsx @@ -160,7 +160,7 @@ const renderDataTable = async (props: Partial) => { // to "Can't perform a React state update on an unmounted component." warnings in tests, // so we need to wait for the next animation frame to avoid this await screen.findByTestId('discoverDocTable'); - await act(() => new Promise((resolve) => requestAnimationFrame(() => resolve()))); + await act(() => new Promise((resolve) => requestAnimationFrame(() => resolve(void 0)))); }; async function getComponent(props: UnifiedDataTableProps = getProps()) { @@ -1107,7 +1107,7 @@ describe('UnifiedDataTable', () => { // to "Can't perform a React state update on an unmounted component." warnings in tests, // so we need to wait for the next animation frame to avoid this await screen.findByTestId('unifiedDataTableCompareDocuments'); - await act(() => new Promise((resolve) => requestAnimationFrame(() => resolve()))); + await act(() => new Promise((resolve) => requestAnimationFrame(() => resolve(void 0)))); }; const getFullScreenButton = () => screen.queryByTestId('dataGridFullScreenButton'); diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx index 0b2efc3b172c1..8192ce766caf8 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx @@ -37,7 +37,7 @@ const actWithTimeout = (action: Function, timer: number = 1) => new Promise((resolve) => setTimeout(async () => { await action(); - resolve(); + resolve(void 0); }, timer) ) ); diff --git a/src/plugins/chart_expressions/expression_metric/public/components/metric_vis.test.tsx b/src/plugins/chart_expressions/expression_metric/public/components/metric_vis.test.tsx index a60cad01bc136..fd0892ea12735 100644 --- a/src/plugins/chart_expressions/expression_metric/public/components/metric_vis.test.tsx +++ b/src/plugins/chart_expressions/expression_metric/public/components/metric_vis.test.tsx @@ -561,6 +561,7 @@ describe('MetricVisComponent', function () { componentWithSecondaryDimension .find(Metric) .props() + // @ts-expect-error @types/react@18 - Parameter 'datum' implicitly has an 'any' type. .data?.[0].map((datum) => datum?.extra) ).toMatchInlineSnapshot(` Array [ @@ -602,6 +603,7 @@ describe('MetricVisComponent', function () { componentWithExtraText .find(Metric) .props() + // @ts-expect-error @types/react@18 - Parameter 'datum' implicitly has an 'any' type. .data?.[0].map((datum) => datum?.extra) ).toMatchInlineSnapshot(` Array [ diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.test.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.test.tsx index 448eb16051394..7e3c9bc64c0d8 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.test.tsx +++ b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.test.tsx @@ -35,7 +35,7 @@ const actWithTimeout = (action: Function, timer: number = 1) => new Promise((resolve) => setTimeout(async () => { await action(); - resolve(); + resolve(void 0); }, timer) ) ); diff --git a/src/plugins/discover/public/components/data_types/logs/service_name_cell.tsx b/src/plugins/discover/public/components/data_types/logs/service_name_cell.tsx index e70c3dae4c2af..39d112de5258e 100644 --- a/src/plugins/discover/public/components/data_types/logs/service_name_cell.tsx +++ b/src/plugins/discover/public/components/data_types/logs/service_name_cell.tsx @@ -20,7 +20,7 @@ const AgentIcon = dynamic(() => import('@kbn/custom-icons/src/components/agent_i export const getServiceNameCell = (serviceNameField: string) => (props: DataGridCellValueElementProps) => { - const serviceNameValue = getFieldValue(props.row, serviceNameField); + const serviceNameValue = getFieldValue(props.row, serviceNameField) as string; const agentName = getFieldValue(props.row, AGENT_NAME_FIELD) as AgentName; if (!serviceNameValue) { diff --git a/src/plugins/discover/public/context_awareness/hooks/use_additional_cell_actions.test.tsx b/src/plugins/discover/public/context_awareness/hooks/use_additional_cell_actions.test.tsx index befaaf7718d05..88dffdfa1ce6a 100644 --- a/src/plugins/discover/public/context_awareness/hooks/use_additional_cell_actions.test.tsx +++ b/src/plugins/discover/public/context_awareness/hooks/use_additional_cell_actions.test.tsx @@ -67,7 +67,7 @@ jest }); describe('useAdditionalCellActions', () => { - const initialProps: Parameters[0] = { + const initialProps: React.PropsWithChildren[0]> = { dataSource: createEsqlDataSource(), dataView: dataViewWithTimefieldMock, query: { esql: `FROM ${dataViewWithTimefieldMock.getIndexPattern()}` }, diff --git a/src/plugins/es_ui_shared/static/forms/components/fields/card_radio_group_field.tsx b/src/plugins/es_ui_shared/static/forms/components/fields/card_radio_group_field.tsx index ddf308fb5449b..865e6e45a7650 100644 --- a/src/plugins/es_ui_shared/static/forms/components/fields/card_radio_group_field.tsx +++ b/src/plugins/es_ui_shared/static/forms/components/fields/card_radio_group_field.tsx @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import React, { Fragment, ReactChildren } from 'react'; +import React, { Fragment } from 'react'; import { EuiFormRow, EuiSpacer, EuiCheckableCard, useGeneratedHtmlId } from '@elastic/eui'; import { FieldHook, getFieldValidityAndErrorMessage } from '../../hook_form_lib'; @@ -17,7 +17,7 @@ interface Props { options: Array<{ label: string; value: string; - children: ReactChildren; + children: React.ReactNode; 'data-test-subj'?: string; }>; euiFieldProps?: Record; diff --git a/src/plugins/presentation_util/public/components/floating_actions/floating_actions.tsx b/src/plugins/presentation_util/public/components/floating_actions/floating_actions.tsx index b9de65d46c32b..8eb9ff4f2cef8 100644 --- a/src/plugins/presentation_util/public/components/floating_actions/floating_actions.tsx +++ b/src/plugins/presentation_util/public/components/floating_actions/floating_actions.tsx @@ -56,7 +56,7 @@ export const FloatingActions: FC = ({ trigger: panelHoverTrigger, }; const actions = (await getTriggerCompatibleActions(PANEL_HOVER_TRIGGER, context)) - .filter((action): action is Action & { MenuItem: React.FC } => { + .filter((action): action is Action & { MenuItem: React.FC<{ context: unknown }> } => { return action.MenuItem !== undefined && (disabledActions ?? []).indexOf(action.id) === -1; }) .sort((a, b) => (a.order || 0) - (b.order || 0)); @@ -66,7 +66,6 @@ export const FloatingActions: FC = ({ setFloatingActions( <> {actions.map((action) => - // @ts-expect-error upgrade typescript v5.1.6 React.createElement(action.MenuItem, { key: action.id, context, diff --git a/src/plugins/ui_actions/public/context_menu/open_context_menu.tsx b/src/plugins/ui_actions/public/context_menu/open_context_menu.tsx index c16bd224ed045..ab8a12374a605 100644 --- a/src/plugins/ui_actions/public/context_menu/open_context_menu.tsx +++ b/src/plugins/ui_actions/public/context_menu/open_context_menu.tsx @@ -174,6 +174,7 @@ export function openContextMenu( | undefined' button={container} isOpen={true} closePopover={onClose} diff --git a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/document_entry_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/document_entry_editor.tsx index 850c8b29d063a..016da27d2c051 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/document_entry_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/document_entry_editor.tsx @@ -26,13 +26,14 @@ interface Props { export const DocumentEntryEditor: React.FC = React.memo(({ entry, setEntry }) => { // Name const setName = useCallback( - (e) => setEntry((prevEntry) => ({ ...prevEntry, name: e.target.value })), + (e: React.ChangeEvent) => + setEntry((prevEntry) => ({ ...prevEntry, name: e.target.value })), [setEntry] ); // Sharing const setSharingOptions = useCallback( - (value) => + (value: string) => setEntry((prevEntry) => ({ ...prevEntry, users: value === i18n.SHARING_GLOBAL_OPTION_LABEL ? [] : undefined, diff --git a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx index d970b76e98bd1..8e551781563f1 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index.tsx @@ -50,6 +50,7 @@ import { import { useCreateKnowledgeBaseEntry } from '../../assistant/api/knowledge_base/entries/use_create_knowledge_base_entry'; import { useUpdateKnowledgeBaseEntries } from '../../assistant/api/knowledge_base/entries/use_update_knowledge_base_entries'; import { SETTINGS_UPDATED_TOAST_TITLE } from '../../assistant/settings/translations'; +import { KnowledgeBaseConfig } from '../../assistant/types'; export const KnowledgeBaseSettingsManagement: React.FC = React.memo(() => { const { @@ -68,7 +69,9 @@ export const KnowledgeBaseSettingsManagement: React.FC = React.memo(() => { false // Knowledge Base settings do not require prompts ); - const handleUpdateKnowledgeBaseSettings = useCallback( + const handleUpdateKnowledgeBaseSettings = useCallback< + React.Dispatch> + >( (updatedKnowledgeBase) => { setHasPendingChanges(true); setUpdatedKnowledgeBaseSettings(updatedKnowledgeBase); @@ -148,9 +151,6 @@ export const KnowledgeBaseSettingsManagement: React.FC = React.memo(() => { setSelectedEntry(entry); openFlyout(); }, - onSpaceNameClicked: ({ namespace }: KnowledgeBaseEntryResponse) => { - openFlyout(); - }, isDeleteEnabled: (entry: KnowledgeBaseEntryResponse) => { return !isEsqlSystemEntry(entry); }, diff --git a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index_entry_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index_entry_editor.tsx index 97ae01ad2edd4..19f8cfbbc52ba 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index_entry_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/index_entry_editor.tsx @@ -27,13 +27,14 @@ interface Props { export const IndexEntryEditor: React.FC = React.memo(({ entry, setEntry }) => { // Name const setName = useCallback( - (e) => setEntry((prevEntry) => ({ ...prevEntry, name: e.target.value })), + (e: React.ChangeEvent) => + setEntry((prevEntry) => ({ ...prevEntry, name: e.target.value })), [setEntry] ); // Sharing const setSharingOptions = useCallback( - (value) => + (value: string) => setEntry((prevEntry) => ({ ...prevEntry, users: value === i18n.SHARING_GLOBAL_OPTION_LABEL ? [] : undefined, @@ -96,19 +97,22 @@ export const IndexEntryEditor: React.FC = React.memo(({ entry, setEntry } // Field const setField = useCallback( - (e) => setEntry((prevEntry) => ({ ...prevEntry, field: e.target.value })), + (e: React.ChangeEvent) => + setEntry((prevEntry) => ({ ...prevEntry, field: e.target.value })), [setEntry] ); // Description const setDescription = useCallback( - (e) => setEntry((prevEntry) => ({ ...prevEntry, description: e.target.value })), + (e: React.ChangeEvent) => + setEntry((prevEntry) => ({ ...prevEntry, description: e.target.value })), [setEntry] ); // Query Description const setQueryDescription = useCallback( - (e) => setEntry((prevEntry) => ({ ...prevEntry, queryDescription: e.target.value })), + (e: React.ChangeEvent) => + setEntry((prevEntry) => ({ ...prevEntry, queryDescription: e.target.value })), [setEntry] ); diff --git a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/use_knowledge_base_table.tsx b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/use_knowledge_base_table.tsx index db46d55f4e5d6..380e6ffedf3ce 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/use_knowledge_base_table.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/knowledge_base/knowledge_base_settings_management/use_knowledge_base_table.tsx @@ -46,6 +46,12 @@ export const useKnowledgeBaseTable = () => { onEntryNameClicked, onDeleteActionClicked, onEditActionClicked, + }: { + isDeleteEnabled: (entry: KnowledgeBaseEntryResponse) => boolean; + isEditEnabled: (entry: KnowledgeBaseEntryResponse) => boolean; + onEntryNameClicked: (entry: KnowledgeBaseEntryResponse) => void; + onDeleteActionClicked: (entry: KnowledgeBaseEntryResponse) => void; + onEditActionClicked: (entry: KnowledgeBaseEntryResponse) => void; }): Array> => { return [ { @@ -55,8 +61,8 @@ export const useKnowledgeBaseTable = () => { }, { name: i18n.COLUMN_NAME, - render: ({ id, name }: KnowledgeBaseEntryResponse) => ( - onEntryNameClicked({ id })}>{name} + render: (entry: KnowledgeBaseEntryResponse) => ( + onEntryNameClicked(entry)}>{entry.name} ), sortable: ({ name }: KnowledgeBaseEntryResponse) => name, width: '30%', diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx index f870fd9f7d04e..5e48d85b0384d 100644 --- a/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx @@ -23,7 +23,7 @@ export type HostCellWithFlyoutRendererProps = PropsWithChildren { expect(mockDispatch).not.toHaveBeenCalledWith(refreshAction); state.transient.inFlight = true; + // @ts-expect-error @types/react@18 - Type '() => void' has no properties in common with type '{ children?: ReactNode; }'. rerender(useRefreshHelper); jest.runAllTimers(); diff --git a/x-pack/plugins/canvas/public/routes/workpad/workpad_route.tsx b/x-pack/plugins/canvas/public/routes/workpad/workpad_route.tsx index 733a0b2d2b9af..0f6e2349f1e13 100644 --- a/x-pack/plugins/canvas/public/routes/workpad/workpad_route.tsx +++ b/x-pack/plugins/canvas/public/routes/workpad/workpad_route.tsx @@ -33,6 +33,7 @@ export const WorkpadRoute = () => { { return ; }} @@ -82,6 +83,7 @@ export const ExportWorkpadRoute = () => { return ( { return ; }} diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_explorer/analytics_collection_explorer_table.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_explorer/analytics_collection_explorer_table.tsx index 9666ceb8eac2f..5ac046ef66758 100644 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_explorer/analytics_collection_explorer_table.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_explorer/analytics_collection_explorer_table.tsx @@ -162,6 +162,7 @@ const tableSettings: { }, [ExploreTables.Clicked]: { columns: [ + // @ts-expect-error @types/react@18 - Type '(value: string) => React.JSX.Element' is not assignable to type 'ReactNode' { field: ExploreTableColumns.page, name: i18n.translate( @@ -197,6 +198,7 @@ const tableSettings: { }, [ExploreTables.Referrers]: { columns: [ + // @ts-expect-error @types/react@18 - Type '(value: string) => React.JSX.Element' is not assignable to type 'ReactNode' { field: ExploreTableColumns.page, name: i18n.translate( @@ -232,6 +234,7 @@ const tableSettings: { }, [ExploreTables.Locations]: { columns: [ + // @ts-expect-error @types/react@18 - Type '(value: string) => React.JSX.Element' is not assignable to type 'ReactNode' { field: ExploreTableColumns.location, name: i18n.translate( diff --git a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_overview/analytics_collection_overview_table.tsx b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_overview/analytics_collection_overview_table.tsx index 1cf9f91f08db8..21982d1d94a8d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_overview/analytics_collection_overview_table.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/analytics/components/analytics_collection_view/analytics_collection_overview/analytics_collection_overview_table.tsx @@ -171,6 +171,7 @@ const tableSettings: { }, [ExploreTables.Clicked]: { columns: [ + // @ts-expect-error Type '(value: string) => React.JSX.Element' is not assignable to type 'ReactNode'. { field: ExploreTableColumns.page, name: i18n.translate( @@ -206,6 +207,7 @@ const tableSettings: { }, [ExploreTables.Referrers]: { columns: [ + // @ts-expect-error Type '(value: string) => React.JSX.Element' is not assignable to type 'ReactNode'. { field: ExploreTableColumns.page, name: i18n.translate( @@ -241,6 +243,7 @@ const tableSettings: { }, [ExploreTables.Locations]: { columns: [ + // @ts-expect-error Type '(value: string, data: LocationsTable) => React.JSX.Element' is not assignable to type 'ReactNode'. { field: ExploreTableColumns.location, name: i18n.translate( diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_detail.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_detail.tsx index 62e209d2a5f14..645090ee4b777 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_detail.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/connector_detail/connector_detail.tsx @@ -10,6 +10,8 @@ import { useParams } from 'react-router-dom'; import { useActions, useValues } from 'kea'; +import type { EuiTabProps } from '@elastic/eui'; + import { i18n } from '@kbn/i18n'; import { generateEncodedPath } from '../../../shared/encode_path_params'; @@ -251,7 +253,7 @@ export const ConnectorDetail: React.FC = () => { wrap: false, }, rightSideItems: getHeaderActions(index, connector), - tabs, + tabs: tabs as Array, }} > {selectedTab?.content || null} diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select_option.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select_option.tsx index a458a2d6c2633..ec5a6efa11912 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select_option.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select_option.tsx @@ -32,6 +32,7 @@ export const PipelineSelectOptionDisabled: React.FC<{ disabledReason?: string }> + {/* @ts-expect-error Type 'string | ((commaSeparatedMissingSourceFields: string) => string)' is not assignable to type 'ReactNode' */} {disabledReason ?? EXISTING_PIPELINE_DISABLED_MISSING_SOURCE_FIELDS} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/hooks/use_fetch_agents_data.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/hooks/use_fetch_agents_data.tsx index 2c9fcfe2b16c6..4ea03518620d9 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/hooks/use_fetch_agents_data.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/hooks/use_fetch_agents_data.tsx @@ -139,6 +139,7 @@ export function useFetchAgentsData() { if (urlParams.kuery !== newVal) { history.replace({ + // @ts-expect-error - kuery can't be undefined search: toUrlParams({ ...urlParams, kuery: newVal === '' ? undefined : newVal }), }); } diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/default_to_data_nodes_notice.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/default_to_data_nodes_notice.tsx index b29ddb75c18cf..59e44f4aaee61 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/default_to_data_nodes_notice.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/default_to_data_nodes_notice.tsx @@ -32,7 +32,10 @@ export const DefaultToDataNodesNotice: FunctionComponent<{ phase: PhaseWithAlloc )}

- {nodeAllocationMigrationGuidance} + { + // @ts-expect-error Type '({ docLinks }: Props) => React.JSX.Element' is not assignable to type 'ReactNode'. + nodeAllocationMigrationGuidance + } ); }; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_tiers_nodes_notice.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_tiers_nodes_notice.tsx index 02dbd1baff25f..23a7ecead25f6 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_tiers_nodes_notice.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/no_tiers_nodes_notice.tsx @@ -30,7 +30,10 @@ export const NoTiersAvailableUsingNodeAttributesNotice: FunctionComponent = () = )}

-

{nodeAllocationMigrationGuidance}

+ { + // @ts-expect-error Type '({ docLinks }: Props) => React.JSX.Element' is not assignable to type 'ReactNode'. + nodeAllocationMigrationGuidance + } ); }; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/will_fallback_nodes_notice.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/will_fallback_nodes_notice.tsx index 199f1001f4276..33dc2439a1408 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/will_fallback_nodes_notice.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/data_tier_allocation_field/components/will_fallback_nodes_notice.tsx @@ -41,7 +41,12 @@ export const WillUseFallbackTierUsingNodeAttributesNotice: FunctionComponent -

{nodeAllocationMigrationGuidance}

+

+ { + // @ts-expect-error Type '({ docLinks }: Props) => React.JSX.Element' is not assignable to type 'ReactNode'. + nodeAllocationMigrationGuidance + } +

); }; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx index e98d1f1c2c55a..83f9afefb3b06 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx @@ -319,6 +319,7 @@ export const SearchableSnapshotField: FunctionComponent = ({ fieldNotices={renderInfoCallout()} fullWidth > + {/* @ts-expect-error Type '() => React.JSX.Element' is not assignable to type 'string'. */} {isDisabledDueToLicense ?
: renderField} ); diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/terms.test.tsx b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/terms.test.tsx index 3cc6da91d8755..aa7c75b15d022 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/terms.test.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/terms/terms.test.tsx @@ -2284,6 +2284,7 @@ describe('terms', () => { expect(select.prop('value')).toEqual('alphabetical'); + // @ts-expect-error @types/react@18 - Parameter 'option' implicitly has an 'any' type. expect(select.prop('options')!.map((option) => option.value)).toEqual([ 'column$$$col2', 'alphabetical', @@ -2311,6 +2312,7 @@ describe('terms', () => { expect(select.prop('value')).toEqual('alphabetical'); + // @ts-expect-error @types/react@18 - Parameter 'option' implicitly has an 'any' type. expect(select.prop('options')!.map((option) => option.value)).toEqual([ 'column$$$col2', 'alphabetical', @@ -2372,6 +2374,7 @@ describe('terms', () => { const selection = instance.find(EuiButtonGroup); expect(selection.prop('idSelected')).toContain('asc'); + // @ts-expect-error @types/react@18 - Parameter 'option' implicitly has an 'any' type. expect(selection.prop('options').map((option) => option.value)).toEqual(['asc', 'desc']); }); diff --git a/x-pack/plugins/ml/public/alerting/anomaly_detection_alerts_table/alert_actions.tsx b/x-pack/plugins/ml/public/alerting/anomaly_detection_alerts_table/alert_actions.tsx index 91ab60d47263f..82c39ac0d8013 100644 --- a/x-pack/plugins/ml/public/alerting/anomaly_detection_alerts_table/alert_actions.tsx +++ b/x-pack/plugins/ml/public/alerting/anomaly_detection_alerts_table/alert_actions.tsx @@ -123,9 +123,12 @@ export function AlertActions(props: AlertActionsProps) { , ] : []), - DefaultAlertActions, ]; + if (DefaultAlertActions) { + actionsMenuItems.push(DefaultAlertActions); + } + const actionsToolTip = actionsMenuItems.length <= 0 ? i18n.translate('xpack.ml.alertsTable.notEnoughPermissions', { diff --git a/x-pack/plugins/ml/public/application/components/custom_hooks/use_create_ad_links.ts b/x-pack/plugins/ml/public/application/components/custom_hooks/use_create_ad_links.ts index c2534eb66cbec..64693e3515c1f 100644 --- a/x-pack/plugins/ml/public/application/components/custom_hooks/use_create_ad_links.ts +++ b/x-pack/plugins/ml/public/application/components/custom_hooks/use_create_ad_links.ts @@ -12,6 +12,7 @@ import { ANOMALY_DETECTION_ENABLE_TIME_RANGE, } from '../../../../common/constants/settings'; import { createResultsUrlForJobs } from '../../util/results_url'; +import type { MlSummaryJob } from '../../../../common'; export const useCreateADLinks = () => { const { @@ -23,7 +24,7 @@ export const useCreateADLinks = () => { const useUserTimeSettings = useUiSettings().get(ANOMALY_DETECTION_ENABLE_TIME_RANGE); const userTimeSettings = useUiSettings().get(ANOMALY_DETECTION_DEFAULT_TIME_RANGE); const createLinkWithUserDefaults = useCallback( - (location, jobList) => { + (location: string, jobList: MlSummaryJob[]) => { const resultsUrl = createResultsUrlForJobs( jobList, location, diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx index d0197f23d5fd5..a6520f964c7b8 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/transaction_details/waterfall_with_summary/waterfall_container/waterfall/accordion_waterfall.tsx @@ -127,6 +127,7 @@ function Waterfall(props: WaterfallProps) { {({ registerChild }) => ( {({ width }) => ( + // @ts-expect-error @types/react@18 Type 'HTMLDivElement' is not assignable to type 'ReactNode'
diff --git a/x-pack/plugins/observability_solution/apm/public/plugin.ts b/x-pack/plugins/observability_solution/apm/public/plugin.ts index f58b9d6d40969..85580d6d866a4 100644 --- a/x-pack/plugins/observability_solution/apm/public/plugin.ts +++ b/x-pack/plugins/observability_solution/apm/public/plugin.ts @@ -293,16 +293,19 @@ export class ApmPlugin implements Plugin { // Registers custom component that is going to be render on fleet section pluginSetupDeps.home?.tutorials.registerCustomComponent( 'TutorialFleetInstructions', + // @ts-expect-error @types/react@18 is not assignable to type 'ReactNode'. Types in registerCustomComponent are incorrect () => import('./tutorial/tutorial_fleet_instructions') ); pluginSetupDeps.home?.tutorials.registerCustomComponent( 'TutorialConfigAgent', + // @ts-expect-error @types/react@18 is not assignable to type 'ReactNode'. Types in registerCustomComponent are incorrect () => import('./tutorial/config_agent') ); pluginSetupDeps.home?.tutorials.registerCustomComponent( 'TutorialConfigAgentRumScript', + // @ts-expect-error @types/react@18 is not assignable to type 'ReactNode'. Types in registerCustomComponent are incorrect () => import('./tutorial/config_agent/rum_script') ); diff --git a/x-pack/plugins/observability_solution/observability_shared/public/components/page_template/page_template.tsx b/x-pack/plugins/observability_solution/observability_shared/public/components/page_template/page_template.tsx index f485da7047a50..1c0b70d3e1af0 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/components/page_template/page_template.tsx +++ b/x-pack/plugins/observability_solution/observability_shared/public/components/page_template/page_template.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { EuiSideNavItemType, EuiPageSectionProps, EuiEmptyPromptProps } from '@elastic/eui'; +import { EuiSideNavItemType, EuiPageSectionProps } from '@elastic/eui'; import { _EuiPageBottomBarProps } from '@elastic/eui/src/components/page_template/bottom_bar/page_bottom_bar'; import { i18n } from '@kbn/i18n'; import React, { useMemo } from 'react'; @@ -31,7 +31,13 @@ import { NavNameWithBetaBadge } from './nav_name_with_beta_badge'; export type WrappedPageTemplateProps = Pick< KibanaPageTemplateProps, - 'children' | 'data-test-subj' | 'pageHeader' | 'restrictWidth' | 'isEmptyState' | 'noDataConfig' + | 'children' + | 'data-test-subj' + | 'pageHeader' + | 'restrictWidth' + | 'isEmptyState' + | 'noDataConfig' + | 'paddingSize' > & { showSolutionNav?: boolean; isPageDataLoaded?: boolean; @@ -39,7 +45,7 @@ export type WrappedPageTemplateProps = Pick< bottomBar?: React.ReactNode; bottomBarProps?: _EuiPageBottomBarProps; topSearchBar?: React.ReactNode; -} & Pick; +}; export interface NavigationEntry { // the label of the menu entry, should be translated diff --git a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/links/step_details_link.tsx b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/links/step_details_link.tsx index bd7476a1568f4..a69f1120cc347 100644 --- a/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/links/step_details_link.tsx +++ b/x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/common/links/step_details_link.tsx @@ -43,6 +43,7 @@ export const StepDetailsLinkIcon = ({ iconType="apmTrace" href={stepDetailsLink} > + {/* @ts-expect-error Type '(stepIndex?: number) => string' is not assignable to type 'ReactNode'.*/} {label ?? VIEW_DETAILS} ); diff --git a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx index 50dfe808139dc..66edc1101a48f 100644 --- a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx +++ b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx @@ -193,7 +193,7 @@ export const OsqueryManagedPolicyCreateImportExtension = React.memo< const { isValid, setFieldValue } = configForm; const agentsLinkHref = useCallback( - (policyId) => { + (policyId: string) => { if (!policy?.policy_ids?.length) return '#'; return getUrlForApp(PLUGIN_ID, { diff --git a/x-pack/plugins/search_indices/public/components/indices/details_page.tsx b/x-pack/plugins/search_indices/public/components/indices/details_page.tsx index ce44bffb045ca..d7a359f56a6f4 100644 --- a/x-pack/plugins/search_indices/public/components/indices/details_page.tsx +++ b/x-pack/plugins/search_indices/public/components/indices/details_page.tsx @@ -93,7 +93,7 @@ export const SearchIndexDetailsPage = () => { }, [detailsPageTabs, tabId]); const handleTabClick = useCallback( - (tab) => { + (tab: EuiTabbedContentTab) => { history.push(`index_details/${indexName}/${tab.id}`); }, diff --git a/x-pack/plugins/search_indices/public/components/indices/indices_router.tsx b/x-pack/plugins/search_indices/public/components/indices/indices_router.tsx index f6c931d73a99e..51527a7d2ef8e 100644 --- a/x-pack/plugins/search_indices/public/components/indices/indices_router.tsx +++ b/x-pack/plugins/search_indices/public/components/indices/indices_router.tsx @@ -29,7 +29,12 @@ export const SearchIndicesRouter: React.FC = () => { /> - application.navigateToApp('elasticsearchStart')} /> + { + application.navigateToApp('elasticsearchStart'); + return null; + }} + /> ); diff --git a/x-pack/plugins/search_indices/public/components/start/elasticsearch_start.tsx b/x-pack/plugins/search_indices/public/components/start/elasticsearch_start.tsx index 8d6e85bfc900a..429af48bac332 100644 --- a/x-pack/plugins/search_indices/public/components/start/elasticsearch_start.tsx +++ b/x-pack/plugins/search_indices/public/components/start/elasticsearch_start.tsx @@ -79,7 +79,7 @@ export const ElasticsearchStart = ({ userPrivileges }: ElasticsearchStartProps) }, [cloud, http]); const onChangeView = useCallback( - (id) => { + (id: string) => { switch (id) { case CreateIndexView.UI: usageTracker.click(AnalyticsEvents.startPageShowCreateIndexUIClick); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/analyzer_panels/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/analyzer_panels/index.tsx index 379ee6cafbd60..ff1e0cd73e7a3 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/analyzer_panels/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/analyzer_panels/index.tsx @@ -11,6 +11,7 @@ import { FlyoutBody } from '@kbn/security-solution-common'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import type { DocumentDetailsAnalyzerPanelKey } from '../shared/constants/panel_keys'; import { DetailsPanel } from '../../../resolver/view/details_panel'; +import type { NodeEventOnClick } from '../../../resolver/view/panels/node_events_of_type'; import { DocumentDetailsPreviewPanelKey } from '../shared/constants/panel_keys'; import { ALERT_PREVIEW_BANNER } from '../preview/constants'; @@ -32,7 +33,7 @@ export interface AnalyzerPanelExpandableFlyoutProps extends FlyoutPanelProps { export const AnalyzerPanel: React.FC = ({ resolverComponentInstanceID }) => { const { openPreviewPanel } = useExpandableFlyoutApi(); - const openPreview = useCallback( + const openPreview = useCallback( ({ documentId, indexName, scopeId }) => () => { openPreviewPanel({ diff --git a/x-pack/plugins/security_solution/public/management/pages/blocklist/view/components/blocklist_form.tsx b/x-pack/plugins/security_solution/public/management/pages/blocklist/view/components/blocklist_form.tsx index d4640aed42c11..2163a0f156833 100644 --- a/x-pack/plugins/security_solution/public/management/pages/blocklist/view/components/blocklist_form.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/blocklist/view/components/blocklist_form.tsx @@ -30,7 +30,10 @@ import { uniq } from 'lodash'; import { ListOperatorEnum, ListOperatorTypeEnum } from '@kbn/securitysolution-io-ts-list-types'; import { OS_TITLES } from '../../../../common/translations'; -import type { ArtifactFormComponentProps } from '../../../../components/artifact_list_page'; +import type { + ArtifactFormComponentOnChangeCallbackProps, + ArtifactFormComponentProps, +} from '../../../../components/artifact_list_page'; import { CONDITIONS_HEADER, CONDITIONS_HEADER_DESCRIPTION, @@ -237,7 +240,7 @@ export const BlockListForm = memo( return selectableFields; }, [selectedOs, getTestId]); - const operatorOptions: Array> = useMemo(() => { + const operatorOptions: Array> = useMemo(() => { return [ { value: isOneOfOperator.type, @@ -423,7 +426,7 @@ export const BlockListForm = memo( ); const handleOperatorUpdate = useCallback( - (newOperator) => { + (newOperator: ListOperatorTypeEnum) => { const nextItem = { ...item, entries: [ @@ -437,7 +440,8 @@ export const BlockListForm = memo( onChange({ isValid: isValid(errorsRef.current), - item: nextItem, + // Type ListOperatorTypeEnum is not assignable to type "wildcard" + item: nextItem as ArtifactFormComponentOnChangeCallbackProps['item'], }); }, [item, blocklistEntry, generateBlocklistEntryValue, onChange] diff --git a/x-pack/plugins/security_solution_serverless/public/upselling/register_upsellings.tsx b/x-pack/plugins/security_solution_serverless/public/upselling/register_upsellings.tsx index 851bf6010cb44..d238148dcc0b0 100644 --- a/x-pack/plugins/security_solution_serverless/public/upselling/register_upsellings.tsx +++ b/x-pack/plugins/security_solution_serverless/public/upselling/register_upsellings.tsx @@ -76,6 +76,7 @@ const configurePluginsUpsellings = (upsellingService: UpsellingService, services const { integrationAssistant } = services; upsellingService.sections$.subscribe((sections) => { + // @ts-expect-error Type 'FunctionComponent<{}>' is not assignable to type 'ReactNode'. integrationAssistant?.renderUpselling(sections.get('integration_assistant')); }); }; diff --git a/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx b/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx index 6f4b2b5570b4d..4474b5266880d 100644 --- a/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx +++ b/x-pack/plugins/session_view/public/components/process_tree_alerts_filter/index.tsx @@ -127,7 +127,7 @@ export const ProcessTreeAlertsFilter = ({ defaultMessage="{count, plural, one {Showing # alert} other {Showing # alerts}}" values={{ count: totalAlertsCount, - bold: (str: string) => {str}, + bold: (str) => {str}, }} /> )} diff --git a/x-pack/plugins/spaces/public/management/edit_space/edit_space_content_tab.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/edit_space_content_tab.test.tsx index 209f65b9a6783..bb55cea5cd50f 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/edit_space_content_tab.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/edit_space_content_tab.test.tsx @@ -39,7 +39,7 @@ const theme = themeServiceMock.createStartContract(); const i18n = i18nServiceMock.createStartContract(); const logger = loggingSystemMock.createLogger(); -const TestComponent: React.FC = ({ children }) => { +const TestComponent: React.FC = ({ children }) => { return ( { deleteSpaceSpy.mockReset(); }); - const TestComponent: React.FC = ({ children }) => { + const TestComponent: React.FC = ({ children }) => { return ( { const loadRolesSpy = jest.spyOn(spacesManager, 'getRolesForSpace'); const toastErrorSpy = jest.spyOn(notifications.toasts, 'addError'); - const TestComponent: React.FC = ({ children }) => { + const TestComponent: React.FC = ({ children }) => { return ( =2.0.0 <4.0.0": version "2.4.28"