diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md index b886aafcfc00fa..2fd84730957b68 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchbar.md @@ -7,7 +7,7 @@ Signature: ```typescript -SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "indexPatterns" | "dataTestSubj" | "refreshInterval" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; } ``` diff --git a/package.json b/package.json index 4bbad7147154c4..649e6dab98218e 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "**/prismjs": "1.22.0", "**/request": "^2.88.2", "**/trim": "0.0.3", - "**/typescript": "4.0.2" + "**/typescript": "4.1.2" }, "engines": { "node": "12.19.1", @@ -824,7 +824,7 @@ "topojson-client": "3.0.0", "ts-loader": "^7.0.5", "tsd": "^0.13.1", - "typescript": "4.0.2", + "typescript": "4.1.2", "typescript-fsa": "^3.0.0", "typescript-fsa-reducers": "^1.2.1", "unlazy-loader": "^0.1.3", diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/kbn-es-archiver/src/cli.ts index 87df07fe865bdc..d65f5a5b23cd0d 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/kbn-es-archiver/src/cli.ts @@ -228,7 +228,7 @@ export function runCli() { output: process.stdout, }); - await new Promise((resolveInput) => { + await new Promise((resolveInput) => { rl.question(`Press enter when you're done`, () => { rl.close(); resolveInput(); diff --git a/src/core/public/application/application_service.test.ts b/src/core/public/application/application_service.test.ts index afcebc06506c26..cd186f87b3a878 100644 --- a/src/core/public/application/application_service.test.ts +++ b/src/core/public/application/application_service.test.ts @@ -697,7 +697,7 @@ describe('#start()', () => { // Create an app and a promise that allows us to control when the app completes mounting const createWaitingApp = (props: Partial): [App, () => void] => { let finishMount: () => void; - const mountPromise = new Promise((resolve) => (finishMount = resolve)); + const mountPromise = new Promise((resolve) => (finishMount = resolve)); const app = { id: 'some-id', title: 'some-title', diff --git a/src/core/public/application/integration_tests/application_service.test.tsx b/src/core/public/application/integration_tests/application_service.test.tsx index 82933576bc4938..2ccb8ec64f9104 100644 --- a/src/core/public/application/integration_tests/application_service.test.tsx +++ b/src/core/public/application/integration_tests/application_service.test.tsx @@ -66,7 +66,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -100,7 +100,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -442,7 +442,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -480,7 +480,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); diff --git a/src/core/public/application/ui/app_container.test.tsx b/src/core/public/application/ui/app_container.test.tsx index f6cde54e6f5025..50c332dacc34a8 100644 --- a/src/core/public/application/ui/app_container.test.tsx +++ b/src/core/public/application/ui/app_container.test.tsx @@ -38,7 +38,7 @@ describe('AppContainer', () => { }); const flushPromises = async () => { - await new Promise(async (resolve) => { + await new Promise(async (resolve) => { setImmediate(() => resolve()); }); }; diff --git a/src/core/public/ui_settings/ui_settings_api.ts b/src/core/public/ui_settings/ui_settings_api.ts index c5efced0a41e3f..175f70a05ec7e1 100644 --- a/src/core/public/ui_settings/ui_settings_api.ts +++ b/src/core/public/ui_settings/ui_settings_api.ts @@ -70,7 +70,7 @@ export class UiSettingsApi { if (error) { reject(error); } else { - resolve(resp); + resolve(resp!); } }, }; diff --git a/src/core/server/elasticsearch/client/cluster_client.test.ts b/src/core/server/elasticsearch/client/cluster_client.test.ts index 429fea65704d87..1127619040fff3 100644 --- a/src/core/server/elasticsearch/client/cluster_client.test.ts +++ b/src/core/server/elasticsearch/client/cluster_client.test.ts @@ -419,7 +419,7 @@ describe('ClusterClient', () => { let closeScopedClient: () => void; internalClient.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeInternalClient = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); @@ -427,7 +427,7 @@ describe('ClusterClient', () => { }) ); scopedClient.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeScopedClient = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); diff --git a/src/core/server/logging/appenders/file/file_appender.ts b/src/core/server/logging/appenders/file/file_appender.ts index c86ea4972324cf..2d9ac121480687 100644 --- a/src/core/server/logging/appenders/file/file_appender.ts +++ b/src/core/server/logging/appenders/file/file_appender.ts @@ -71,7 +71,7 @@ export class FileAppender implements DisposableAppender { * Disposes `FileAppender`. Waits for the underlying file stream to be completely flushed and closed. */ public async dispose() { - await new Promise((resolve) => { + await new Promise((resolve) => { if (this.outputStream === undefined) { return resolve(); } diff --git a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx index e9fa2833c3db5f..ad938d339f681e 100644 --- a/src/plugins/advanced_settings/public/management_app/components/field/field.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/field/field.tsx @@ -263,7 +263,7 @@ export class Field extends PureComponent { return new Promise((resolve, reject) => { reader.onload = () => { - resolve(reader.result || undefined); + resolve(reader.result!); }; reader.onerror = (err) => { reject(err); diff --git a/src/plugins/bfetch/public/batching/create_streaming_batched_function.test.ts b/src/plugins/bfetch/public/batching/create_streaming_batched_function.test.ts index da6c940c48d0ae..d7dde8f1b93d33 100644 --- a/src/plugins/bfetch/public/batching/create_streaming_batched_function.test.ts +++ b/src/plugins/bfetch/public/batching/create_streaming_batched_function.test.ts @@ -30,7 +30,7 @@ const getPromiseState = (promise: Promise): Promise<'resolved' | 'rejec () => resolve('rejected') ) ), - new Promise<'pending'>((resolve) => resolve()).then(() => 'pending'), + new Promise<'pending'>((resolve) => resolve('pending')).then(() => 'pending'), ]); const isPending = (promise: Promise): Promise => diff --git a/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts b/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts index 84b12c97f1856b..34f43886df66e7 100644 --- a/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts +++ b/src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts @@ -74,7 +74,7 @@ export class LegacyCoreEditor implements CoreEditor { // dirty check for tokenizer state, uses a lot less cycles // than listening for tokenizerUpdate waitForLatestTokens(): Promise { - return new Promise((resolve) => { + return new Promise((resolve) => { const session = this.editor.getSession(); const checkInterval = 25; @@ -239,7 +239,7 @@ export class LegacyCoreEditor implements CoreEditor { private forceRetokenize() { const session = this.editor.getSession(); - return new Promise((resolve) => { + return new Promise((resolve) => { // force update of tokens, but not on this thread to allow for ace rendering. setTimeout(function () { let i; diff --git a/src/plugins/console/server/lib/proxy_request.ts b/src/plugins/console/server/lib/proxy_request.ts index 27e19d920ad174..b6d7fc97f49a8b 100644 --- a/src/plugins/console/server/lib/proxy_request.ts +++ b/src/plugins/console/server/lib/proxy_request.ts @@ -110,7 +110,7 @@ export const proxyRequest = ({ if (!resolved) { timeoutReject(Boom.gatewayTimeout('Client request timeout')); } else { - timeoutResolve(); + timeoutResolve(undefined); } }, timeout); }); diff --git a/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx b/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx index 933d2766d13f47..dcce38cdf94cec 100644 --- a/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx +++ b/src/plugins/dashboard/public/application/actions/expand_panel_action.tsx @@ -20,7 +20,11 @@ import { i18n } from '@kbn/i18n'; import { IEmbeddable } from '../../embeddable_plugin'; import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin'; -import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable'; +import { + DASHBOARD_CONTAINER_TYPE, + DashboardContainer, + DashboardContainerInput, +} from '../embeddable'; export const ACTION_EXPAND_PANEL = 'togglePanel'; @@ -33,7 +37,9 @@ function isExpanded(embeddable: IEmbeddable) { throw new IncompatibleActionError(); } - return embeddable.id === embeddable.parent.getInput().expandedPanelId; + return ( + embeddable.id === (embeddable.parent.getInput() as DashboardContainerInput).expandedPanelId + ); } export interface ExpandPanelActionContext { diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 836a49c3d96205..ec8b9a1ad3a44e 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -2045,8 +2045,8 @@ export const search: { // Warning: (ae-missing-release-tag) "SearchBar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export const SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & { - WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; +export const SearchBar: React.ComponentClass, "query" | "isLoading" | "filters" | "indexPatterns" | "dataTestSubj" | "refreshInterval" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & { + WrappedComponent: React.ComponentType & ReactIntl.InjectedIntlProps>; }; // Warning: (ae-forgotten-export) The symbol "SearchBarOwnProps" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx b/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx index 4a539b618f817f..e44c05b3a88a95 100644 --- a/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx +++ b/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx @@ -47,7 +47,7 @@ export function ChangeIndexPattern({ indexPatternRefs: IndexPatternRef[]; onChangeIndexPattern: (newId: string) => void; indexPatternId?: string; - selectableProps?: EuiSelectableProps; + selectableProps?: EuiSelectableProps<{ value: string }>; }) { const [isPopoverOpen, setPopoverIsOpen] = useState(false); @@ -86,7 +86,7 @@ export function ChangeIndexPattern({ defaultMessage: 'Change index pattern', })} - data-test-subj="indexPattern-switcher" {...selectableProps} searchable diff --git a/src/plugins/embeddable/public/lib/containers/container.ts b/src/plugins/embeddable/public/lib/containers/container.ts index 292d7d3bf7a1e3..1426ade147d307 100644 --- a/src/plugins/embeddable/public/lib/containers/container.ts +++ b/src/plugins/embeddable/public/lib/containers/container.ts @@ -171,7 +171,7 @@ export abstract class Container< return this.children[id] as TEmbeddable; } - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const subscription = merge(this.getOutput$(), this.getInput$()).subscribe(() => { if (this.output.embeddableLoaded[id]) { subscription.unsubscribe(); @@ -181,6 +181,7 @@ export abstract class Container< // If we hit this, the panel was removed before the embeddable finished loading. if (this.input.panels[id] === undefined) { subscription.unsubscribe(); + // @ts-expect-error undefined in not assignable to TEmbeddable | ErrorEmbeddable resolve(undefined); } }); diff --git a/src/plugins/embeddable/public/lib/state_transfer/types.ts b/src/plugins/embeddable/public/lib/state_transfer/types.ts index d8b4f4801bba3c..d36954528dbf02 100644 --- a/src/plugins/embeddable/public/lib/state_transfer/types.ts +++ b/src/plugins/embeddable/public/lib/state_transfer/types.ts @@ -53,7 +53,7 @@ export function isEmbeddablePackageState(state: unknown): state is EmbeddablePac function ensureFieldOfTypeExists(key: string, obj: unknown, type?: string): boolean { return ( - obj && + Boolean(obj) && key in (obj as { [key: string]: unknown }) && (!type || typeof (obj as { [key: string]: unknown })[key] === type) ); diff --git a/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory.tsx b/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory.tsx index 893b6b04e50bcd..b6a7137c1e421c 100644 --- a/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory.tsx +++ b/src/plugins/embeddable/public/lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory.tsx @@ -56,6 +56,7 @@ export class ContactCardEmbeddableFactory { modalSession.close(); + // @ts-expect-error resolve(undefined); }} onCreate={(input: { firstName: string; lastName?: string }) => { diff --git a/src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form.ts b/src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form.ts index 869d1fac54b1ea..a509331ef1900b 100644 --- a/src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form.ts +++ b/src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form.ts @@ -149,7 +149,7 @@ export function useForm( return; } - return new Promise((resolve) => { + return new Promise((resolve) => { setTimeout(() => { areSomeFieldValidating = fieldsToArray().some((field) => field.isValidating); if (areSomeFieldValidating) { diff --git a/src/plugins/expressions/common/expression_types/expression_type.test.ts b/src/plugins/expressions/common/expression_types/expression_type.test.ts index b94d9a305121fe..2976697e0299f3 100644 --- a/src/plugins/expressions/common/expression_types/expression_type.test.ts +++ b/src/plugins/expressions/common/expression_types/expression_type.test.ts @@ -44,7 +44,7 @@ export const render: ExpressionTypeDefinition<'render', ExpressionValueRender(v: T): ExpressionValueRender => ({ - type: name, + type: 'render', as: 'debug', value: v, }), diff --git a/src/plugins/expressions/public/render.test.ts b/src/plugins/expressions/public/render.test.ts index 97a37d49147ec9..c44683f6779c05 100644 --- a/src/plugins/expressions/public/render.test.ts +++ b/src/plugins/expressions/public/render.test.ts @@ -129,7 +129,7 @@ describe('ExpressionRenderHandler', () => { it('sends a next observable once rendering is complete', () => { const expressionRenderHandler = new ExpressionRenderHandler(element); expect.assertions(1); - return new Promise((resolve) => { + return new Promise((resolve) => { expressionRenderHandler.render$.subscribe((renderCount) => { expect(renderCount).toBe(1); resolve(); diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/ensure_minimum_time.test.ts b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/ensure_minimum_time.test.ts index a38f3cbd8fe815..5a202bff53b644 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/ensure_minimum_time.test.ts +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/lib/ensure_minimum_time.test.ts @@ -38,7 +38,7 @@ describe('ensureMinimumTime', () => { it('resolves in the amount of time provided, at minimum', async (done) => { const startTime = new Date().getTime(); - const promise = new Promise((resolve) => resolve()); + const promise = new Promise((resolve) => resolve()); await ensureMinimumTime(promise, 100); const endTime = new Date().getTime(); expect(endTime - startTime).toBeGreaterThanOrEqual(100); diff --git a/src/plugins/kibana_utils/common/of.test.ts b/src/plugins/kibana_utils/common/of.test.ts index 9ff8997f637e56..a262bfa708d0aa 100644 --- a/src/plugins/kibana_utils/common/of.test.ts +++ b/src/plugins/kibana_utils/common/of.test.ts @@ -21,7 +21,7 @@ import { of } from './of'; describe('of()', () => { describe('when promise resolves', () => { - const promise = new Promise((resolve) => resolve()).then(() => 123); + const promise = new Promise((resolve) => resolve()).then(() => 123); test('first member of 3-tuple is the promise value', async () => { const [result] = await of(promise); @@ -40,7 +40,7 @@ describe('of()', () => { }); describe('when promise rejects', () => { - const promise = new Promise((resolve) => resolve()).then(() => { + const promise = new Promise((resolve) => resolve()).then(() => { // eslint-disable-next-line no-throw-literal throw 123; }); diff --git a/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.test.ts b/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.test.ts index 39a2db12ffad16..7f971d44af9620 100644 --- a/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.test.ts +++ b/src/plugins/visualize/public/application/utils/use/use_visualize_app_state.test.ts @@ -199,7 +199,7 @@ describe('useVisualizeAppState', () => { renderHook(() => useVisualizeAppState(mockServices, eventEmitter, savedVisInstance)); - await new Promise((res) => { + await new Promise((res) => { setTimeout(() => res()); }); diff --git a/x-pack/plugins/beats_management/public/components/inputs/code_editor.tsx b/x-pack/plugins/beats_management/public/components/inputs/code_editor.tsx index 46ea90a9c1b301..78eecf79848659 100644 --- a/x-pack/plugins/beats_management/public/components/inputs/code_editor.tsx +++ b/x-pack/plugins/beats_management/public/components/inputs/code_editor.tsx @@ -68,6 +68,7 @@ class CodeEditor extends Component< public render() { const { + name, id, label, isReadOnly, diff --git a/x-pack/plugins/beats_management/public/components/inputs/input.tsx b/x-pack/plugins/beats_management/public/components/inputs/input.tsx index 29cdcfccfc756c..17f2f95070c59c 100644 --- a/x-pack/plugins/beats_management/public/components/inputs/input.tsx +++ b/x-pack/plugins/beats_management/public/components/inputs/input.tsx @@ -71,6 +71,7 @@ class FieldText extends Component< public render() { const { + name, id, required, label, diff --git a/x-pack/plugins/beats_management/public/components/inputs/multi_input.tsx b/x-pack/plugins/beats_management/public/components/inputs/multi_input.tsx index 16bcf1b3b9a06b..ed0d67bb221495 100644 --- a/x-pack/plugins/beats_management/public/components/inputs/multi_input.tsx +++ b/x-pack/plugins/beats_management/public/components/inputs/multi_input.tsx @@ -73,6 +73,7 @@ class MultiFieldText extends Component< public render() { const { + name, id, required, label, diff --git a/x-pack/plugins/beats_management/public/components/inputs/password_input.tsx b/x-pack/plugins/beats_management/public/components/inputs/password_input.tsx index 30f4cb85fb58c1..edb8cf6ab3abc4 100644 --- a/x-pack/plugins/beats_management/public/components/inputs/password_input.tsx +++ b/x-pack/plugins/beats_management/public/components/inputs/password_input.tsx @@ -67,6 +67,7 @@ class FieldPassword extends Component< public render() { const { + name, id, required, label, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/location.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/location.ts index 5c0ca74f5225ac..4eed89b95132a3 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/location.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/browser/location.ts @@ -28,7 +28,7 @@ export function location(): ExpressionFunctionDefinition<'location', null, {}, P help, fn: () => { return new Promise((resolve) => { - function createLocation(geoposition: Position) { + function createLocation(geoposition: GeolocationPosition) { const { latitude, longitude } = geoposition.coords; return resolve({ type: 'datatable', diff --git a/x-pack/plugins/canvas/shareable_runtime/test/utils.ts b/x-pack/plugins/canvas/shareable_runtime/test/utils.ts index 5e65594972da2e..939343b6a28c5e 100644 --- a/x-pack/plugins/canvas/shareable_runtime/test/utils.ts +++ b/x-pack/plugins/canvas/shareable_runtime/test/utils.ts @@ -21,7 +21,7 @@ export const takeMountedSnapshot = (mountedComponent: ReactWrapper<{}, {}, Compo }; export const waitFor = (fn: () => boolean, stepMs = 100, failAfterMs = 1000) => { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let waitForTimeout: NodeJS.Timeout; const tryCondition = () => { diff --git a/x-pack/plugins/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts b/x-pack/plugins/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts index 40e7691e621fd3..30de6c0802713a 100644 --- a/x-pack/plugins/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts +++ b/x-pack/plugins/discover_enhanced/public/actions/explore_data/abstract_explore_data_action.ts @@ -42,7 +42,7 @@ export abstract class AbstractExploreDataAction; + protected abstract getUrl(context: Context): Promise; public async isCompatible({ embeddable }: Context): Promise { if (!embeddable) return false; diff --git a/x-pack/plugins/fleet/scripts/dev_agent/script.ts b/x-pack/plugins/fleet/scripts/dev_agent/script.ts index 18ce12794776af..3babb03c2dac69 100644 --- a/x-pack/plugins/fleet/scripts/dev_agent/script.ts +++ b/x-pack/plugins/fleet/scripts/dev_agent/script.ts @@ -45,7 +45,7 @@ run( while (!closing) { await checkin(kibanaUrl, agent, log); - await new Promise((resolve, reject) => setTimeout(() => resolve(), CHECKIN_INTERVAL)); + await new Promise((resolve, reject) => setTimeout(() => resolve(), CHECKIN_INTERVAL)); } }, { diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts index 28ddf9704bd925..9c87eaa1859cd2 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.test.ts @@ -85,9 +85,9 @@ describe('test agent checkin new action services', () => { it('should not fetch actions concurrently', async () => { const observable = createNewActionsSharedObservable(); - const resolves: Array<() => void> = []; + const resolves: Array<(value?: any) => void> = []; getMockedNewActionSince().mockImplementation(() => { - return new Promise((resolve) => { + return new Promise((resolve) => { resolves.push(resolve); }); }); diff --git a/x-pack/plugins/fleet/server/services/epm/archive/extract.ts b/x-pack/plugins/fleet/server/services/epm/archive/extract.ts index 6ac81a25dfc21e..1e8f7ce416df19 100644 --- a/x-pack/plugins/fleet/server/services/epm/archive/extract.ts +++ b/x-pack/plugins/fleet/server/services/epm/archive/extract.ts @@ -69,7 +69,7 @@ export function getBufferExtractor( function yauzlFromBuffer(buffer: Buffer, opts: yauzl.Options): Promise { return new Promise((resolve, reject) => yauzl.fromBuffer(buffer, opts, (err?: Error, handle?: yauzl.ZipFile) => - err ? reject(err) : resolve(handle) + err ? reject(err) : resolve(handle!) ) ); } @@ -80,7 +80,7 @@ function getZipReadStream( ): Promise { return new Promise((resolve, reject) => zipfile.openReadStream(entry, (err?: Error, readStream?: NodeJS.ReadableStream) => - err ? reject(err) : resolve(readStream) + err ? reject(err) : resolve(readStream!) ) ); } diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts index a3b4cb604231f5..ef09dbfcb2674b 100644 --- a/x-pack/plugins/infra/server/plugin.ts +++ b/x-pack/plugins/infra/server/plugin.ts @@ -88,7 +88,7 @@ export class InfraServerPlugin { } async setup(core: CoreSetup, plugins: InfraServerPluginDeps) { - await new Promise((resolve) => { + await new Promise((resolve) => { this.config$.subscribe((configValue) => { this.config = configValue; resolve(); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx index 6b7e5ba8ea89d8..93b4a4e3bea207 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx @@ -19,10 +19,9 @@ export const ConfigPanelWrapper = memo(function ConfigPanelWrapper(props: Config const activeVisualization = props.visualizationMap[props.activeVisualizationId || '']; const { visualizationState } = props; - return ( - activeVisualization && - visualizationState && - ); + return activeVisualization && visualizationState ? ( + + ) : null; }); function LayerPanels( diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index f5b31fb8811672..67c6068dd4d91c 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -37,9 +37,9 @@ function isConfiguration( value: unknown ): value is { columnId: string; groupId: string; layerId: string } { return ( - value && + Boolean(value) && typeof value === 'object' && - 'columnId' in value && + 'columnId' in value! && 'groupId' in value && 'layerId' in value ); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts index 647c0f3ac9cca7..766812b192ed1c 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts @@ -110,21 +110,21 @@ export const validateDatasourceAndVisualization = ( longMessage: string; }> | undefined => { - const layersGroups = - currentVisualizationState && - currentVisualization - ?.getLayerIds(currentVisualizationState) - .reduce>((memo, layerId) => { - const groups = currentVisualization?.getConfiguration({ - frame: frameAPI, - layerId, - state: currentVisualizationState, - }).groups; - if (groups) { - memo[layerId] = groups; - } - return memo; - }, {}); + const layersGroups = currentVisualizationState + ? currentVisualization + ?.getLayerIds(currentVisualizationState) + .reduce>((memo, layerId) => { + const groups = currentVisualization?.getConfiguration({ + frame: frameAPI, + layerId, + state: currentVisualizationState, + }).groups; + if (groups) { + memo[layerId] = groups; + } + return memo; + }, {}) + : undefined; const datasourceValidationErrors = currentDatasourceState ? currentDataSource?.getErrorMessages(currentDatasourceState, layersGroups) diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/change_indexpattern.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/change_indexpattern.tsx index 3c9e19d30d38fc..25cb34d19beb8d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/change_indexpattern.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/change_indexpattern.tsx @@ -6,8 +6,7 @@ import { i18n } from '@kbn/i18n'; import React, { useState } from 'react'; -import { EuiPopover, EuiPopoverTitle, EuiSelectable } from '@elastic/eui'; -import { EuiSelectableProps } from '@elastic/eui/src/components/selectable/selectable'; +import { EuiPopover, EuiPopoverTitle, EuiSelectable, EuiSelectableProps } from '@elastic/eui'; import { IndexPatternRef } from './types'; import { trackUiEvent } from '../lens_ui_telemetry'; import { ToolbarButtonProps, ToolbarButton } from '../shared_components'; @@ -63,7 +62,12 @@ export function ChangeIndexPattern({ defaultMessage: 'Change index pattern', })} - {...selectableProps} searchable singleSelection="always" diff --git a/x-pack/plugins/licensing/server/on_pre_response_handler.test.ts b/x-pack/plugins/licensing/server/on_pre_response_handler.test.ts index af3ec42ab4ec5d..b21a821ec6a723 100644 --- a/x-pack/plugins/licensing/server/on_pre_response_handler.test.ts +++ b/x-pack/plugins/licensing/server/on_pre_response_handler.test.ts @@ -46,7 +46,7 @@ describe('createOnPreResponseHandler', () => { const license$ = new BehaviorSubject(licenseMock.createLicense({ signature: 'foo' })); const refresh = jest.fn().mockImplementation( () => - new Promise((resolve) => { + new Promise((resolve) => { setTimeout(() => { license$.next(updatedLicense); resolve(); diff --git a/x-pack/plugins/lists/public/common/hooks/use_async.test.ts b/x-pack/plugins/lists/public/common/hooks/use_async.test.ts index 33f28cfc97291c..6ae7aa25fc3bf2 100644 --- a/x-pack/plugins/lists/public/common/hooks/use_async.test.ts +++ b/x-pack/plugins/lists/public/common/hooks/use_async.test.ts @@ -80,7 +80,7 @@ describe('useAsync', () => { it('populates the loading state while the function is pending', async () => { let resolve: () => void; - fn.mockImplementation(() => new Promise((_resolve) => (resolve = _resolve))); + fn.mockImplementation(() => new Promise((_resolve) => (resolve = _resolve))); const { result, waitForNextUpdate } = renderHook(() => useAsync(fn)); diff --git a/x-pack/plugins/reporting/server/browsers/download/download.ts b/x-pack/plugins/reporting/server/browsers/download/download.ts index b4b303416facd0..a8637679a76d70 100644 --- a/x-pack/plugins/reporting/server/browsers/download/download.ts +++ b/x-pack/plugins/reporting/server/browsers/download/download.ts @@ -36,7 +36,7 @@ export async function download(url: string, path: string, logger: GenericLevelLo hash.update(chunk); }); - await new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { resp.data .on('error', (err: Error) => { logger.error(err); diff --git a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts index 31164fa14bfb0e..c67c277350c806 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts @@ -24,7 +24,7 @@ import { createMockReportingCore } from '../../test_helpers'; import { runTaskFnFactory } from './execute_job'; import { TaskPayloadCSV } from './types'; -const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve(), ms)); +const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve(), ms)); const puid = new Puid(); const getRandomScrollId = () => { diff --git a/x-pack/plugins/reporting/server/lib/screenshots/wait_for_render.ts b/x-pack/plugins/reporting/server/lib/screenshots/wait_for_render.ts index edd4f71b2adacc..429c5d88d7dbbf 100644 --- a/x-pack/plugins/reporting/server/lib/screenshots/wait_for_render.ts +++ b/x-pack/plugins/reporting/server/lib/screenshots/wait_for_render.ts @@ -36,7 +36,7 @@ export const waitForRenderComplete = async ( const renderedTasks = []; function waitForRender(visualization: Element) { - return new Promise((resolve) => { + return new Promise((resolve) => { visualization.addEventListener('renderComplete', () => resolve()); }); } diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx index c58cb12f03a192..68daf427677ffd 100644 --- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx @@ -25,7 +25,7 @@ const waitForRender = async ( wrapper: ReactWrapper, condition: (wrapper: ReactWrapper) => boolean ) => { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const interval = setInterval(async () => { await Promise.resolve(); wrapper.update(); diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx index 98e59eb95f0daf..7e83c3654cac30 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.tsx @@ -413,7 +413,7 @@ export class RoleMappingsGridPage extends Component { 'xpack.security.management.roleMappings.actionDeleteAriaLabel', { defaultMessage: `Delete '{name}'`, - values: { name }, + values: { name: record.name }, } )} iconType="trash" diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx index cfb57f8a8a8d5c..69229e2aef7eb0 100644 --- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx @@ -24,7 +24,7 @@ const waitForRender = async ( wrapper: ReactWrapper, condition: (wrapper: ReactWrapper) => boolean ) => { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const interval = setInterval(async () => { await Promise.resolve(); wrapper.update(); diff --git a/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts b/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts index 71ef6496ef6cad..de0c915d0c14c3 100644 --- a/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts +++ b/x-pack/plugins/security/public/session/unauthorized_response_http_interceptor.test.ts @@ -34,7 +34,7 @@ afterEach(() => { it(`logs out 401 responses`, async () => { const http = setupHttp('/foo'); const sessionExpired = new SessionExpired(`${http.basePath}/logout`, tenant); - const logoutPromise = new Promise((resolve) => { + const logoutPromise = new Promise((resolve) => { jest.spyOn(sessionExpired, 'logout').mockImplementation(() => resolve()); }); const interceptor = new UnauthorizedResponseHttpInterceptor(sessionExpired, http.anonymousPaths); diff --git a/x-pack/plugins/security_solution/public/common/utils/clone_http_fetch_query.ts b/x-pack/plugins/security_solution/public/common/utils/clone_http_fetch_query.ts index 90b81df8bc21e6..809542c6b2faa6 100644 --- a/x-pack/plugins/security_solution/public/common/utils/clone_http_fetch_query.ts +++ b/x-pack/plugins/security_solution/public/common/utils/clone_http_fetch_query.ts @@ -11,7 +11,7 @@ export function cloneHttpFetchQuery(query: Immutable): HttpFetch const clone: HttpFetchQuery = {}; for (const [key, value] of Object.entries(query)) { if (Array.isArray(value)) { - clone[key] = [...value]; + clone[key] = [...value] as string[] | number[] | boolean[]; } else { // Array.isArray is not removing ImmutableArray from the union. clone[key] = value as string | number | boolean; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.test.tsx index b631d37140a38f..564b382b7b29f9 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/columns.test.tsx @@ -40,7 +40,7 @@ describe('AllRulesTable Columns', () => { test('duplicate rule onClick should call refetch after the rule is duplicated', async () => { (duplicateRulesAction as jest.Mock).mockImplementation( () => - new Promise((resolve) => + new Promise((resolve) => setTimeout(() => { results.push('duplicateRulesAction'); resolve(); @@ -62,7 +62,7 @@ describe('AllRulesTable Columns', () => { test('delete rule onClick should call refetch after the rule is deleted', async () => { (deleteRulesAction as jest.Mock).mockImplementation( () => - new Promise((resolve) => + new Promise((resolve) => setTimeout(() => { results.push('deleteRulesAction'); resolve(); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/state/async_resource_state.ts b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/state/async_resource_state.ts index bb868418e7f0df..5265cee2e59729 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/state/async_resource_state.ts +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/state/async_resource_state.ts @@ -136,8 +136,8 @@ export const getCurrentResourceError = ( }; export const isOutdatedResourceState = ( - state: AsyncResourceState, - isFresh: (data: Data) => boolean + state: Immutable>, + isFresh: (data: Immutable) => boolean ): boolean => isUninitialisedResourceState(state) || (isLoadedResourceState(state) && !isFresh(state.data)) || diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/store/selectors.ts b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/store/selectors.ts index 589fbac03a7e20..e7c21e1a997645 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/store/selectors.ts +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/store/selectors.ts @@ -35,7 +35,7 @@ export const needsRefreshOfListData = (state: Immutable { return ( data.pageIndex === location.page_index && diff --git a/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx b/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx index 2a538620dce0be..7c0f4b7969aa8c 100644 --- a/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx +++ b/x-pack/plugins/security_solution/public/resolver/test_utilities/simulator/index.tsx @@ -202,7 +202,7 @@ export class Simulator { while (timeoutCount < 10) { timeoutCount++; yield mapper(); - await new Promise((resolve) => { + await new Promise((resolve) => { setTimeout(() => { this.forceAutoSizerOpen(); this.wrapper.update(); diff --git a/x-pack/plugins/security_solution/public/resolver/view/use_camera.test.tsx b/x-pack/plugins/security_solution/public/resolver/view/use_camera.test.tsx index 35cf2c36d6627f..4e49617b6c8b18 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/use_camera.test.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/use_camera.test.tsx @@ -66,7 +66,7 @@ describe('useCamera on an unpainted element', () => { while (timeoutCount < 10) { timeoutCount++; yield mapper(); - await new Promise((resolve) => { + await new Promise((resolve) => { setTimeout(() => { wrapper.update(); resolve(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/duration/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/duration/index.tsx index 1106ee63a03cba..ef36d78e51a7c1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/duration/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/duration/index.tsx @@ -23,6 +23,7 @@ export const Duration = React.memo<{ }>(({ contextId, eventId, fieldName, value }) => ( (({ contextId, eventId, fieldName, value }) => ( { [ { id: `id-exists`, - name, + name: 'name', enabled: true, excluded: false, kqlQuery: '', diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/check_timelines_status.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/check_timelines_status.ts index b5aa24336b2d7c..3f7cf3f9760305 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/check_timelines_status.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/check_timelines_status.ts @@ -48,8 +48,8 @@ export const checkTimelinesStatus = async ( readStream, (timelinesFromFileSystem: T) => { if (Array.isArray(timelinesFromFileSystem)) { - const parsedTimelinesFromFileSystem = timelinesFromFileSystem.map((t: string) => - JSON.parse(t) + const parsedTimelinesFromFileSystem = (timelinesFromFileSystem as readonly string[]).map( + (t) => JSON.parse(t) ); const prepackagedTimelines = timeline.timeline ?? []; const timelinesToInstall = getTimelinesToInstall( diff --git a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/hdfs_settings.tsx b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/hdfs_settings.tsx index 2d7a56f33be848..99a9713521c514 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/hdfs_settings.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/hdfs_settings.tsx @@ -37,6 +37,7 @@ export const HDFSSettings: React.FunctionComponent = ({ settingErrors, }) => { const { + name, settings: { delegateType, uri, diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx index 4ccec36fba040a..335828a9856d38 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx @@ -249,7 +249,11 @@ export const RepositoryTable: React.FunctionComponent = ({ , { const task3 = createTask(); const task4 = createTask(); - return new Promise((resolve) => { + return new Promise((resolve) => { Promise.all([bufferedUpdate(task1), bufferedUpdate(task2)]).then((_) => { expect(bulkUpdate).toHaveBeenCalledTimes(1); expect(bulkUpdate).toHaveBeenCalledWith([task1, task2]); @@ -146,7 +146,7 @@ describe('Bulk Operation Buffer', () => { expect(bulkUpdate).toHaveBeenCalledTimes(1); expect(bulkUpdate).toHaveBeenCalledWith([task1, task2]); - return new Promise((resolve) => { + return new Promise((resolve) => { const futureUpdates = Promise.all([bufferedUpdate(task3), bufferedUpdate(task4)]); setTimeout(() => { diff --git a/x-pack/plugins/task_manager/server/monitoring/configuration_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/configuration_statistics.test.ts index f97861901b5b5b..6f3dcb33d5bf5b 100644 --- a/x-pack/plugins/task_manager/server/monitoring/configuration_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/configuration_statistics.test.ts @@ -36,7 +36,7 @@ describe('Configuration Statistics Aggregator', () => { pollIntervalConfiguration$: new Subject(), }; - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve, reject) => { createConfigurationAggregator(configuration, managedConfig) .pipe(take(3), bufferCount(3)) .subscribe(([initial, updatedWorkers, updatedInterval]) => { diff --git a/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.test.ts b/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.test.ts index 8479def5deeebb..b8502dee9a8efa 100644 --- a/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/monitoring_stats_stream.test.ts @@ -36,7 +36,7 @@ describe('createMonitoringStatsStream', () => { }; it('returns the initial config used to configure Task Manager', async () => { - return new Promise((resolve) => { + return new Promise((resolve) => { createMonitoringStatsStream(of(), configuration) .pipe(take(1)) .subscribe((firstValue) => { @@ -49,7 +49,7 @@ describe('createMonitoringStatsStream', () => { it('incrementally updates the stats returned by the endpoint', async () => { const aggregatedStats$ = new Subject(); - return new Promise((resolve) => { + return new Promise((resolve) => { createMonitoringStatsStream(aggregatedStats$, configuration) .pipe(take(3), bufferCount(3)) .subscribe(([initialValue, secondValue, thirdValue]) => { diff --git a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts index 6ab866b6167acc..538acd51bb792c 100644 --- a/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/task_run_statistics.test.ts @@ -60,7 +60,7 @@ describe('Task Run Statistics', () => { }); } - return new Promise((resolve) => { + return new Promise((resolve) => { taskRunAggregator .pipe( // skip initial stat which is just initialized data which @@ -128,7 +128,7 @@ describe('Task Run Statistics', () => { } } - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { taskRunAggregator .pipe( // skip initial stat which is just initialized data which @@ -224,7 +224,7 @@ describe('Task Run Statistics', () => { runningAverageWindowSize ); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { taskRunAggregator .pipe( // skip initial stat which is just initialized data which @@ -303,7 +303,7 @@ describe('Task Run Statistics', () => { runningAverageWindowSize ); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { taskRunAggregator .pipe( // skip initial stat which is just initialized data which @@ -394,7 +394,7 @@ describe('Task Run Statistics', () => { runningAverageWindowSize ); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { taskRunAggregator .pipe( // skip initial stat which is just initialized data which diff --git a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts index 3470ee4d764864..21c9f429814cac 100644 --- a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts @@ -86,7 +86,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe(() => { expect(taskStore.aggregate).toHaveBeenCalledWith({ aggs: { @@ -253,7 +253,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe((result) => { expect(result.key).toEqual('workload'); expect(result.value).toMatchObject({ @@ -283,7 +283,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise(async (resolve) => { + return new Promise(async (resolve) => { workloadAggregator.pipe(first()).subscribe((result) => { expect(result.key).toEqual('workload'); expect(result.value).toMatchObject({ @@ -319,7 +319,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe((result) => { expect(result.key).toEqual('workload'); expect(result.value).toMatchObject({ @@ -342,7 +342,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe((result) => { expect(result.key).toEqual('workload'); expect(result.value).toMatchObject({ @@ -370,7 +370,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe(() => { expect(taskStore.aggregate.mock.calls[0][0]).toMatchObject({ aggs: { @@ -408,7 +408,7 @@ describe('Workload Statistics Aggregator', () => { loggingSystemMock.create().get() ); - return new Promise((resolve) => { + return new Promise((resolve) => { workloadAggregator.pipe(first()).subscribe((result) => { expect(taskStore.aggregate.mock.calls[0][0]).toMatchObject({ aggs: { @@ -453,7 +453,7 @@ describe('Workload Statistics Aggregator', () => { const logger = loggingSystemMock.create().get(); const workloadAggregator = createWorkloadAggregator(taskStore, of(true), 10, 3000, logger); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { workloadAggregator.pipe(take(2), bufferCount(2)).subscribe((results) => { expect(results[0].key).toEqual('workload'); expect(results[0].value).toMatchObject({ @@ -491,7 +491,7 @@ describe('Workload Statistics Aggregator', () => { logger ); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let errorWasThrowAt = 0; taskStore.aggregate.mockImplementation(async () => { if (errorWasThrowAt === 0) { diff --git a/x-pack/plugins/task_manager/server/polling/observable_monitor.test.ts b/x-pack/plugins/task_manager/server/polling/observable_monitor.test.ts index 0b7bbdfb623e5f..8fe2d59eee1250 100644 --- a/x-pack/plugins/task_manager/server/polling/observable_monitor.test.ts +++ b/x-pack/plugins/task_manager/server/polling/observable_monitor.test.ts @@ -25,7 +25,7 @@ describe('Poll Monitor', () => { expect(instantiator).not.toHaveBeenCalled(); - return new Promise((resolve) => { + return new Promise((resolve) => { const next = jest.fn(); monitoredObservable.pipe(take(3)).subscribe({ next, @@ -45,7 +45,7 @@ describe('Poll Monitor', () => { const instantiator = jest.fn(() => interval(100)); const monitoredObservable = createObservableMonitor(instantiator, { heartbeatInterval }); - return new Promise((resolve) => { + return new Promise((resolve) => { const next = jest.fn(); monitoredObservable.pipe(take(3)).subscribe({ next, @@ -79,7 +79,7 @@ describe('Poll Monitor', () => { const onError = jest.fn(); const monitoredObservable = createObservableMonitor(instantiator, { onError }); - return new Promise((resolve) => { + return new Promise((resolve) => { const next = jest.fn(); const error = jest.fn(); monitoredObservable @@ -135,7 +135,7 @@ describe('Poll Monitor', () => { inactivityTimeout: 500, }); - return new Promise((resolve) => { + return new Promise((resolve) => { const next = jest.fn(); const error = jest.fn(); monitoredObservable diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index 06d33da8f1f555..c9048eda45fe84 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -689,7 +689,7 @@ export const waitFor = async ( maxTimeout: number = 10000, timeoutWait: number = 10 ): Promise => { - await new Promise(async (resolve, reject) => { + await new Promise(async (resolve, reject) => { let found = false; let numberOfTries = 0; while (!found && numberOfTries < Math.floor(maxTimeout / timeoutWait)) { diff --git a/x-pack/test/functional_enterprise_search/services/app_search_client.ts b/x-pack/test/functional_enterprise_search/services/app_search_client.ts index fbd15b83f97ea7..f85ecd53903aef 100644 --- a/x-pack/test/functional_enterprise_search/services/app_search_client.ts +++ b/x-pack/test/functional_enterprise_search/services/app_search_client.ts @@ -104,7 +104,7 @@ const search = async (engineName: string): Promise => { // Since the App Search API does not issue document receipts, the only way to tell whether or not documents // are fully indexed is to poll the search endpoint. export const waitForIndexedDocs = (engineName: string) => { - return new Promise(async function (resolve) { + return new Promise(async function (resolve) { let isReady = false; while (!isReady) { const response = await search(engineName); diff --git a/x-pack/test/lists_api_integration/utils.ts b/x-pack/test/lists_api_integration/utils.ts index 224048e868d7f0..53472b459b8acd 100644 --- a/x-pack/test/lists_api_integration/utils.ts +++ b/x-pack/test/lists_api_integration/utils.ts @@ -115,7 +115,7 @@ export const waitFor = async ( maxTimeout: number = 5000, timeoutWait: number = 10 ) => { - await new Promise(async (resolve, reject) => { + await new Promise(async (resolve, reject) => { let found = false; let numberOfTries = 0; while (!found && numberOfTries < Math.floor(maxTimeout / timeoutWait)) { diff --git a/x-pack/test/security_api_integration/tests/oidc/implicit_flow/oidc_auth.ts b/x-pack/test/security_api_integration/tests/oidc/implicit_flow/oidc_auth.ts index ced9598809e108..4552df4cf2b38c 100644 --- a/x-pack/test/security_api_integration/tests/oidc/implicit_flow/oidc_auth.ts +++ b/x-pack/test/security_api_integration/tests/oidc/implicit_flow/oidc_auth.ts @@ -46,7 +46,7 @@ export default function ({ getService }: FtrProviderContext) { // JSDOM doesn't support changing of `window.location` and throws an exception if script // tries to do that and we have to workaround this behaviour. We also need to wait until our // script is loaded and executed, __isScriptExecuted__ is used exactly for that. - (window as Record).__isScriptExecuted__ = new Promise((resolve) => { + (window as Record).__isScriptExecuted__ = new Promise((resolve) => { Object.defineProperty(window, 'location', { value: { href: diff --git a/x-pack/test/security_api_integration/tests/token/header.ts b/x-pack/test/security_api_integration/tests/token/header.ts index 2150d7a6269b0c..53b50286cc6cc7 100644 --- a/x-pack/test/security_api_integration/tests/token/header.ts +++ b/x-pack/test/security_api_integration/tests/token/header.ts @@ -66,7 +66,7 @@ export default function ({ getService }: FtrProviderContext) { // Access token expiration is set to 15s for API integration tests. // Let's wait for 20s to make sure token expires. - await new Promise((resolve) => setTimeout(() => resolve(), 20000)); + await new Promise((resolve) => setTimeout(resolve, 20000)); await supertest .get('/internal/security/me') diff --git a/x-pack/test/security_api_integration/tests/token/session.ts b/x-pack/test/security_api_integration/tests/token/session.ts index 30e004a0fff3c5..daee8264bd0bdb 100644 --- a/x-pack/test/security_api_integration/tests/token/session.ts +++ b/x-pack/test/security_api_integration/tests/token/session.ts @@ -8,7 +8,7 @@ import request, { Cookie } from 'request'; import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve(), ms)); +const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertestWithoutAuth'); diff --git a/yarn.lock b/yarn.lock index 8efcf7f6d85ed9..bf598eb07a004b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27828,10 +27828,10 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@4.0.2, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" - integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== +typescript@4.1.2, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.2.tgz#6369ef22516fe5e10304aae5a5c4862db55380e9" + integrity sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== ua-parser-js@^0.7.18: version "0.7.22"