From d902348a07aa0a878fc7b95962dbf83859dc6223 Mon Sep 17 00:00:00 2001 From: Tommy Markley <5437176+tmarkley@users.noreply.github.com> Date: Sun, 4 Dec 2022 20:03:53 +0000 Subject: [PATCH] Upgrades TypeScript to 4.1, fixes simple errors * Reduces number of errors from 517 across 260 files to 216 across 115 files (~58% reduction). * The remaining type errors are documented in #1660. Signed-off-by: Tommy Markley <5437176+tmarkley@users.noreply.github.com> --- CHANGELOG.md | 1 + .../public/by_value/input_editor.tsx | 2 +- .../public/components/basic_tab.tsx | 2 +- .../public/components/playground_section.tsx | 2 +- examples/routing_example/public/services.ts | 8 ++-- .../search_examples/public/components/app.tsx | 2 +- package.json | 4 +- packages/osd-ace/package.json | 2 +- packages/osd-analytics/package.json | 2 +- packages/osd-analytics/src/reporter.ts | 2 +- packages/osd-apm-config-loader/package.json | 2 +- packages/osd-apm-config-loader/src/config.ts | 6 +-- packages/osd-config-schema/package.json | 2 +- .../src/errors/schema_error.test.ts | 2 +- .../osd-config-schema/src/internals/index.ts | 14 +++--- packages/osd-config/package.json | 2 +- packages/osd-cross-platform/package.json | 2 +- packages/osd-cross-platform/src/path.test.ts | 4 +- packages/osd-cross-platform/src/path.ts | 4 +- packages/osd-cross-platform/src/repo_root.ts | 2 +- packages/osd-dev-utils/package.json | 2 +- .../ci_stats_reporter/ci_stats_reporter.ts | 2 +- .../src/osd_client/osd_client_requester.ts | 2 +- .../osd-dev-utils/src/precommit_hook/cli.ts | 2 +- .../osd-dev-utils/src/proc_runner/proc.ts | 6 +-- packages/osd-dev-utils/src/run/cleanup.ts | 2 +- packages/osd-dev-utils/src/run/run.ts | 2 +- .../src/run/run_with_commands.ts | 2 +- packages/osd-i18n/package.json | 2 +- packages/osd-i18n/src/core/i18n.ts | 4 +- packages/osd-logging/package.json | 2 +- packages/osd-monaco/package.json | 2 +- packages/osd-monaco/src/xjson/grammar.ts | 2 +- packages/osd-opensearch-archiver/src/cli.ts | 4 +- .../src/lib/archives/parse.test.ts | 4 +- .../lib/docs/generate_doc_records_stream.ts | 2 +- .../lib/docs/index_doc_records_stream.test.ts | 2 +- .../src/lib/docs/index_doc_records_stream.ts | 4 +- .../src/lib/indices/create_index_stream.ts | 4 +- .../src/lib/indices/delete_index.ts | 2 +- .../src/lib/indices/delete_index_stream.ts | 2 +- .../indices/generate_index_records_stream.ts | 2 +- .../src/lib/stats.test.ts | 2 +- .../src/lib/streams/intersperse_stream.ts | 2 +- .../src/lib/streams/map_stream.ts | 2 +- .../src/lib/streams/reduce_stream.ts | 2 +- .../src/lib/streams/replace_stream.ts | 2 +- .../src/lib/streams/split_stream.ts | 4 +- packages/osd-optimizer/src/common/bundle.ts | 6 +-- .../osd-optimizer/src/common/bundle_cache.ts | 6 +-- .../osd-optimizer/src/common/bundle_refs.ts | 2 +- .../src/common/event_stream_helpers.ts | 2 +- .../osd-optimizer/src/common/worker_config.ts | 2 +- packages/osd-optimizer/src/limits.ts | 2 +- packages/osd-optimizer/src/node/cache.ts | 4 +- .../src/node/node_auto_tranpilation.ts | 2 +- .../osd-optimizer/src/optimizer/cache_keys.ts | 2 +- .../src/optimizer/optimizer_config.ts | 2 +- packages/osd-optimizer/src/run_optimizer.ts | 2 +- .../osd-optimizer/src/worker/run_compilers.ts | 2 +- packages/osd-plugin-helpers/package.json | 2 +- packages/osd-plugin-helpers/src/cli.ts | 6 +-- packages/osd-plugin-helpers/src/config.ts | 2 +- .../src/tasks/update_versions.ts | 4 +- packages/osd-pm/package.json | 2 +- packages/osd-pm/src/commands/watch.ts | 2 +- packages/osd-pm/src/run.ts | 2 +- .../osd-pm/src/utils/bootstrap_cache_file.ts | 4 +- packages/osd-pm/src/utils/child_process.ts | 4 +- packages/osd-pm/src/utils/fs.ts | 4 +- packages/osd-pm/src/utils/parallelize.ts | 2 +- packages/osd-pm/src/utils/scripts.ts | 2 +- packages/osd-pm/src/utils/yarn_lock.ts | 2 +- packages/osd-std/package.json | 2 +- packages/osd-telemetry-tools/package.json | 2 +- .../src/cli/run_telemetry_check.ts | 2 +- .../src/cli/run_telemetry_extract.ts | 2 +- .../src/tools/check_collector_integrity.ts | 6 +-- .../src/tools/tasks/parse_configs_task.ts | 2 +- .../src/tools/ts_parser.ts | 2 +- .../src/failed_tests_reporter/github_api.ts | 2 +- .../src/functional_test_runner/cli.ts | 2 +- .../functional_test_runner.ts | 2 +- .../lib/config/read_config_file.test.ts | 2 +- .../docker_servers/docker_servers_service.ts | 4 +- .../lib/lifecycle_phase.ts | 2 +- .../functional_test_runner/lib/load_tracer.ts | 2 +- .../lib/providers/provider_collection.ts | 2 +- .../lib/providers/verbose_instance.ts | 2 +- packages/osd-utils/package.json | 2 +- packages/osd-utils/src/path/index.ts | 2 +- .../reload_logging_config.test.ts | 6 +-- .../application/application_service.test.ts | 2 +- .../application_service.test.tsx | 8 ++-- .../application/ui/app_container.test.tsx | 2 +- .../public/application/ui/app_container.tsx | 2 +- .../chrome/ui/header/header_action_menu.tsx | 2 +- .../public/core_app/status/lib/load_status.ts | 2 +- .../public/core_app/status/status_app.tsx | 2 +- src/core/public/core_system.ts | 4 +- src/core/public/http/fetch.ts | 8 ++-- src/core/public/http/intercept.ts | 2 +- .../injected_metadata_service.ts | 10 +++-- .../saved_objects/saved_objects_client.ts | 2 +- .../ui_settings/ui_settings_api.test.ts | 2 +- .../public/ui_settings/ui_settings_api.ts | 6 +-- .../public/ui_settings/ui_settings_client.ts | 2 +- src/core/server/bootstrap.ts | 4 +- .../environment/create_data_folder.test.ts | 2 +- .../server/environment/create_data_folder.ts | 2 +- src/core/server/environment/resolve_uuid.ts | 4 +- .../server/http/cookie_session_storage.ts | 4 +- src/core/server/http/http_server.test.ts | 12 +++--- src/core/server/http/http_tools.test.ts | 2 +- src/core/server/http/https_redirect_server.ts | 2 +- src/core/server/http/lifecycle/auth.ts | 2 +- .../server/http/lifecycle/on_post_auth.ts | 2 +- src/core/server/http/lifecycle/on_pre_auth.ts | 2 +- .../server/http/lifecycle/on_pre_response.ts | 2 +- .../server/http/lifecycle/on_pre_routing.ts | 2 +- src/core/server/http/router/error_wrapper.ts | 2 +- src/core/server/http/router/router.ts | 4 +- .../server/http/router/validator/validator.ts | 2 +- src/core/server/legacy/legacy_service.ts | 2 +- .../logging/appenders/file/file_appender.ts | 2 +- src/core/server/metrics/collectors/cgroup.ts | 4 +- src/core/server/metrics/collectors/os.ts | 2 +- .../opensearch/client/cluster_client.test.ts | 4 +- .../opensearch/legacy/cluster_client.ts | 2 +- src/core/server/opensearch/legacy/errors.ts | 2 +- .../ensure_opensearch_version.ts | 2 +- .../discovery/plugin_manifest_parser.ts | 6 +-- .../server/rendering/rendering_service.tsx | 2 +- src/core/server/root/index.ts | 4 +- .../migrations/core/document_migrator.test.ts | 2 +- .../migrations/core/document_migrator.ts | 2 +- .../migrations/core/migrate_raw_docs.ts | 2 +- .../migrations/core/migration_coordinator.ts | 2 +- .../core/migration_opensearch_client.test.ts | 2 +- .../migrations/core/opensearch_index.ts | 2 +- .../server/saved_objects/routes/import.ts | 2 +- .../routes/resolve_import_errors.ts | 2 +- .../saved_objects/service/lib/repository.ts | 2 +- .../lib/repository_create_repository.test.ts | 2 +- .../lib/repository_opensearch_client.test.ts | 2 +- .../lib/repository_opensearch_client.ts | 2 +- .../lib/repository_opensearch_client.ts2 | 2 +- .../service/lib/search_dsl/query_params.ts | 2 +- .../version/decode_version.test.ts | 6 +-- .../create_or_upgrade_saved_config.test.ts | 2 +- .../create_or_upgrade_saved_config.ts | 2 +- src/core/server/ui_settings/routes/delete.ts | 2 +- src/core/server/ui_settings/routes/get.ts | 2 +- src/core/server/ui_settings/routes/set.ts | 2 +- .../server/ui_settings/routes/set_many.ts | 2 +- .../ui_settings/ui_settings_client.test.ts | 14 +++--- .../server/ui_settings/ui_settings_client.ts | 6 +-- .../utils/streams/concat_stream.test.ts | 4 +- .../utils/streams/intersperse_stream.ts | 2 +- src/core/server/utils/streams/map_stream.ts | 2 +- .../streams/promise_from_streams.test.ts | 2 +- .../server/utils/streams/reduce_stream.ts | 2 +- .../server/utils/streams/replace_stream.ts | 2 +- src/core/server/utils/streams/split_stream.ts | 4 +- src/core/utils/context.ts | 2 +- src/dev/build/lib/build.test.ts | 1 + src/dev/build/lib/download.ts | 8 ++-- src/dev/build/lib/fs.ts | 4 +- .../lib/integration_tests/download.test.ts | 8 ++-- .../build/lib/integration_tests/fs.test.ts | 36 ++++++++-------- src/dev/build/lib/runner.test.ts | 1 + src/dev/build/lib/runner.ts | 2 +- src/dev/build/lib/watch_stdio_for_line.ts | 4 +- .../nodejs/download_node_builds_task.test.ts | 1 + .../verify_existing_node_builds_task.test.ts | 1 + .../create_os_package_tasks.test.ts | 1 + .../tasks/os_packages/docker_generator/run.ts | 2 +- .../tasks/patch_native_modules_task.test.ts | 13 +++--- src/dev/i18n/integrate_locale_files.test.ts | 10 ++--- src/dev/i18n/integrate_locale_files.ts | 4 +- src/dev/i18n/tasks/check_configs.ts | 2 +- src/dev/i18n/tasks/merge_configs.ts | 2 +- src/dev/i18n/utils/verify_icu_message.ts | 2 +- src/dev/npm/installed_packages.ts | 2 +- src/dev/prs/github_api.ts | 2 +- src/dev/prs/run_update_prs_cli.ts | 6 +-- src/dev/run_check_published_api_changes.ts | 2 +- src/dev/run_i18n_check.ts | 2 +- src/dev/run_i18n_extract.ts | 2 +- src/dev/run_i18n_integrate.ts | 2 +- src/dev/typescript/build_refs.ts | 2 +- .../telemetry_collectors/working_collector.ts | 2 +- .../server/i18n/get_translations_path.ts | 2 +- .../i18n/localization/file_integrity.ts | 2 +- src/legacy/utils/version.ts | 2 +- .../bundles_route/dynamic_asset_response.ts | 4 +- .../management_app/components/field/field.tsx | 6 +-- .../management_app/components/form/form.tsx | 2 +- .../create_streaming_batched_function.test.ts | 2 +- .../create_streaming_batched_function.ts | 2 +- src/plugins/bfetch/server/plugin.ts | 2 +- .../server/streaming/create_ndjson_stream.ts | 2 +- .../editor/legacy/console_editor/editor.tsx | 2 +- .../hooks/use_data_init/use_data_init.ts | 2 +- .../use_send_current_request_to_opensearch.ts | 4 +- .../legacy_core_editor/legacy_core_editor.ts | 2 +- .../public/lib/autocomplete/autocomplete.ts | 2 +- src/plugins/console/public/lib/utils/index.ts | 2 +- .../console/server/lib/proxy_request.test.ts | 2 +- .../api/console/proxy/create_handler.ts | 2 +- .../embeddable/grid/dashboard_grid.tsx | 2 +- .../viewport/dashboard_viewport.tsx | 3 +- .../attribute_service/attribute_service.tsx | 4 +- src/plugins/dashboard/public/url_generator.ts | 2 +- .../saved_objects/dashboard_migrations.ts | 4 +- .../saved_objects/migrate_match_all_query.ts | 2 +- .../server/saved_objects/migrations_730.ts | 4 +- .../common/field_formats/converters/string.ts | 2 +- .../index_patterns/index_pattern.test.ts | 2 +- .../index_patterns/index_pattern.ts | 2 +- .../index_patterns/index_patterns.test.ts | 2 +- .../index_patterns/index_patterns.ts | 8 ++-- .../common/opensearch_query/kuery/ast/ast.ts | 4 +- .../common/search/aggs/param_types/json.ts | 2 +- .../date_interval_utils/is_valid_interval.ts | 2 +- .../date_interval_utils/parse_interval.ts | 2 +- .../parse_opensearch_interval.test.ts | 4 +- .../search/aggs/utils/get_parsed_value.ts | 2 +- .../data/common/search/search_source/mocks.ts | 1 + .../common/search/search_source/parse_json.ts | 2 +- .../data/common/search/tabify/get_columns.ts | 2 +- .../public/actions/select_range_action.ts | 2 +- .../data/public/actions/value_click_action.ts | 2 +- .../lib/generate_mapping_chain.test.ts | 2 +- .../filter_manager/lib/map_filter.test.ts | 2 +- .../lib/mappers/map_default.test.ts | 2 +- .../lib/mappers/map_exists.test.ts | 2 +- .../lib/mappers/map_geo_bounding_box.test.ts | 2 +- .../lib/mappers/map_geo_polygon.test.ts | 2 +- .../lib/mappers/map_match_all.test.ts | 2 +- .../lib/mappers/map_missing.test.ts | 2 +- .../lib/mappers/map_phrase.test.ts | 2 +- .../lib/mappers/map_query_string.test.ts | 2 +- .../lib/mappers/map_range.test.ts | 2 +- .../lib/mappers/map_spatial_filter.test.ts | 2 +- .../data/public/query/lib/from_user.ts | 2 +- .../saved_query/saved_query_service.test.ts | 4 +- .../query/saved_query/saved_query_service.ts | 2 +- .../search/expressions/opensearchaggs.ts | 2 +- .../search/expressions/opensearchdsl.test.ts | 2 +- .../search/expressions/opensearchdsl.ts | 2 +- .../public/search/search_interceptor.test.ts | 8 ++-- .../ui/filter_bar/filter_editor/index.tsx | 2 +- .../filter_editor/lib/filter_editor_utils.ts | 2 +- .../data/public/ui/filter_bar/filter_item.tsx | 2 +- .../index_pattern_select.tsx | 4 +- .../query_string_input/query_string_input.tsx | 2 +- .../ui/search_bar/lib/use_saved_query.ts | 2 +- .../data/public/ui/search_bar/search_bar.tsx | 2 +- .../autocomplete/value_suggestions_route.ts | 2 +- .../data/server/dql_telemetry/route.ts | 2 +- .../fetcher/lib/opensearch_api.ts | 6 +-- .../fetcher/lib/resolve_time_pattern.ts | 2 +- .../data/server/index_patterns/routes.ts | 8 ++-- .../data/server/search/collectors/register.ts | 2 +- .../data/server/search/collectors/usage.ts | 4 +- .../opensearch_search_strategy.ts | 2 +- .../data/server/search/routes/msearch.ts | 2 +- .../data/server/search/routes/search.ts | 4 +- .../server/audit/logging_auditor.ts | 7 +-- .../server/client/configure_client.ts | 2 +- .../data_source/server/data_source_service.ts | 7 +-- .../server/legacy/configure_legacy_client.ts | 4 +- .../create_data_source_wizard.tsx | 4 +- .../edit_form/edit_data_source_form.test.tsx | 12 +++--- .../edit_form/edit_data_source_form.tsx | 6 +-- .../edit_data_source/edit_data_source.tsx | 4 +- .../public/components/utils.test.ts | 14 +++--- .../public/components/utils.ts | 2 +- .../doc/use_opensearch_doc_search.ts | 2 +- .../sidebar/discover_field_search.tsx | 2 +- .../sidebar/lib/field_calculator.ts | 2 +- .../embeddable/search_embeddable.ts | 2 +- .../embeddable/search_embeddable_factory.ts | 2 +- .../server/saved_objects/search_migrations.ts | 4 +- .../public/lib/containers/container.ts | 4 +- .../public/lib/state_transfer/types.ts | 6 +-- .../embeddable/public/tests/helpers.ts | 4 +- src/plugins/expressions/common/ast/parse.ts | 2 +- .../expressions/common/execution/execution.ts | 4 +- .../common/execution/execution_contract.ts | 2 +- src/plugins/expressions/common/mocks.ts | 2 + src/plugins/expressions/public/render.test.ts | 4 +- src/plugins/expressions/public/render.ts | 2 +- .../routes/fetch_opensearch_hits_status.ts | 2 +- .../services/sample_data/lib/load_data.ts | 6 +-- .../services/sample_data/routes/install.ts | 8 ++-- .../services/sample_data/routes/list.ts | 4 +- .../services/sample_data/routes/uninstall.ts | 4 +- .../sample_data/sample_data_registry.ts | 2 +- .../services/sample_data/usage/collector.ts | 2 +- .../services/sample_data/usage/usage.ts | 4 +- .../services/tutorials/tutorials_registry.ts | 1 - .../components/header/header.tsx | 4 +- .../step_time_field/step_time_field.tsx | 2 +- .../create_index_pattern_wizard.tsx | 6 +-- .../lib/ensure_minimum_time.test.ts | 2 +- .../editors/default/default.tsx | 2 +- .../empty_state/empty_state.tsx | 1 - .../server/routes/preview_scripted_field.ts | 2 +- .../server/routes/resolve_index.ts | 2 +- .../public/components/editor/field_select.tsx | 2 +- .../components/editor/list_control_editor.tsx | 2 +- .../public/control/list_control_factory.ts | 2 +- .../public/control/range_control_factory.ts | 2 +- .../public/angular/angular_config.tsx | 4 +- .../public/angular/subscribe_with_scope.ts | 2 +- .../table_list_view/table_list_view.tsx | 4 +- .../collectors/application_usage/rollups.ts | 6 +-- .../common/of.test.ts | 4 +- .../opensearch_dashboards_utils/common/of.ts | 2 +- .../state_management/state_hash/state_hash.ts | 2 +- .../state_management/url/osd_url_tracker.ts | 2 +- .../create_osd_url_state_storage.ts | 4 +- .../hashed_item_store/hashed_item_store.ts | 2 +- .../public/storage/storage.ts | 4 +- .../components/json_editor/json_editor.tsx | 2 +- .../public/request/send_request.ts | 2 +- .../request/use_request.test.helpers.tsx | 2 +- .../static/validators/string/is_json.ts | 2 +- src/plugins/region_map/public/services.ts | 6 +-- .../helpers/apply_opensearch_resp.ts | 2 +- .../helpers/build_saved_object.ts | 2 +- .../saved_object/helpers/create_source.ts | 2 +- .../saved_object/helpers/save_saved_object.ts | 2 +- .../helpers/save_with_confirmation.ts | 2 +- .../public/saved_object/saved_object.test.ts | 4 +- .../public/lib/create_field_list.ts | 2 +- .../public/lib/import_legacy_file.ts | 2 +- .../public/lib/resolve_saved_objects.ts | 10 ++--- .../object_view/components/field.tsx | 4 +- .../objects_table/components/flyout.tsx | 8 ++-- .../components/relationships.tsx | 2 +- .../objects_table/saved_objects_table.tsx | 8 ++-- .../public/components/url_panel_content.tsx | 2 +- .../server/routes/lib/short_url_lookup.ts | 4 +- .../telemetry_config/get_telemetry_opt_in.ts | 2 +- src/plugins/telemetry/public/plugin.ts | 2 +- .../public/services/telemetry_sender.ts | 2 +- .../public/services/telemetry_service.ts | 6 +-- .../telemetry_plugin_collector.ts | 2 +- .../usage/telemetry_usage_collector.test.ts | 2 +- .../usage/telemetry_usage_collector.ts | 6 +-- src/plugins/telemetry/server/fetcher.ts | 6 +-- src/plugins/telemetry/server/plugin.ts | 2 +- .../server/routes/telemetry_opt_in.ts | 2 +- .../server/routes/telemetry_opt_in_stats.ts | 2 +- .../server/routes/telemetry_usage_stats.ts | 2 +- .../get_data_telemetry/get_data_telemetry.ts | 2 +- .../get_opensearch_dashboards.ts | 2 - .../get_telemetry_saved_object.test.ts | 2 +- .../get_telemetry_saved_object.ts | 2 +- .../update_telemetry_saved_object.ts | 2 +- .../server/plugin.ts | 4 +- .../components/opt_in_example_flyout.tsx | 2 +- .../opt_in_security_example_flyout.tsx | 2 +- .../telemetry_management_section.tsx | 2 +- .../public/panels/timechart/schema.ts | 2 +- .../public/actions/action_internal.ts | 23 +++++++--- .../service/ui_actions_execution_service.ts | 4 +- .../server/collector/collector_set.test.ts | 2 +- .../server/collector/collector_set.ts | 2 +- .../server/routes/report_metrics.ts | 2 +- .../application/components/data_tab/field.tsx | 2 +- .../data_tab/field_selector.test.tsx | 2 +- .../use/use_prefers_reduced_motion.ts | 2 +- .../data_tab/utils/field_calculator.ts | 2 +- .../components/searchable_dropdown.tsx | 12 +++--- .../public/application/utils/breadcrumbs.ts | 6 +-- .../application/utils/get_top_nav_config.tsx | 10 ++--- .../application/utils/use/use_can_save.ts | 2 +- .../utils/use/use_index_pattern.tsx | 2 +- .../utils/use/use_saved_vis_builder_vis.ts | 6 +-- .../utils/vis_builder_state_validation.ts | 2 +- .../vis_builder_embeddable_factory.tsx | 2 +- src/plugins/vis_builder/public/plugin.ts | 4 +- .../saved_visualizations/transforms.test.ts | 4 +- .../table/components/table_viz_options.tsx | 4 +- .../public/components/agg.tsx | 2 +- .../public/components/agg_group.test.tsx | 4 +- .../public/components/agg_group.tsx | 4 +- .../public/components/agg_params_helper.ts | 2 +- .../controls/components/input_list.tsx | 2 +- .../controls/components/number_list/utils.ts | 2 +- .../components/controls/percentiles.test.tsx | 1 - .../components/controls/time_interval.tsx | 2 +- .../components/controls/utils/agg_utils.ts | 2 +- .../components/table_vis_grid_columns.tsx | 43 +++++++++---------- .../timeline_expression_input_helpers.ts | 4 +- .../components/timeline_vis_component.tsx | 2 +- .../helpers/timeline_request_handler.ts | 2 +- .../vis_type_timeline/server/routes/run.ts | 2 +- .../server/routes/fields.ts | 2 +- .../vis_type_timeseries/server/routes/vis.ts | 4 +- .../validation_telemetry_service.ts | 4 +- .../public/components/vega_vis_editor.tsx | 2 +- .../vis_type_vega/public/data_model/utils.ts | 2 +- .../public/data_model/vega_parser.ts | 2 +- .../public/vega_inspector/vega_adapter.ts | 2 +- src/plugins/vis_type_vega/public/vega_type.ts | 2 +- .../usage_collector/get_usage_collector.ts | 4 +- .../create_vis_embeddable_from_object.ts | 2 +- .../visualize_embeddable_factory.tsx | 4 +- .../saved_visualizations.ts | 2 +- .../saved_objects/visualization_migrations.ts | 36 ++++++++-------- .../application/utils/get_top_nav_config.tsx | 2 +- .../utils/use/use_saved_vis_instance.ts | 4 +- .../utils/use/use_visualize_app_state.test.ts | 2 +- .../telemetry/telemetry_optin_notice_seen.ts | 2 +- .../services/retry/retry_for_success.ts | 2 +- test/functional/page_objects/common_page.ts | 4 +- .../functional/page_objects/dashboard_page.ts | 2 +- test/functional/page_objects/login_page.ts | 2 +- test/functional/services/common/browser.ts | 2 +- test/functional/services/common/find.ts | 4 +- .../functional/services/common/screenshots.ts | 2 +- test/functional/services/common/snapshots.ts | 2 +- .../web_element_wrapper.ts | 2 +- .../services/remote/prevent_parallel_calls.ts | 2 +- test/functional/services/remote/remote.ts | 2 +- .../plugins/osd_tp_run_pipeline/package.json | 2 +- .../plugins/app_link_test/package.json | 2 +- .../plugins/core_app_status/package.json | 2 +- .../plugins/core_plugin_a/package.json | 2 +- .../plugins/core_plugin_appleave/package.json | 2 +- .../plugins/core_plugin_b/package.json | 2 +- .../core_plugin_chromeless/package.json | 2 +- .../core_plugin_route_timeouts/package.json | 2 +- .../core_plugin_static_assets/package.json | 2 +- .../plugins/core_provider_plugin/package.json | 2 +- .../plugins/data_search/package.json | 2 +- .../doc_views_links_plugin/package.json | 2 +- .../plugins/doc_views_plugin/package.json | 2 +- .../plugins/index_patterns/package.json | 2 +- .../management_test_plugin/package.json | 2 +- .../opensearch_client_plugin/package.json | 2 +- .../osd_sample_panel_action/package.json | 2 +- .../plugins/osd_top_nav/package.json | 2 +- .../osd_tp_custom_visualizations/package.json | 2 +- .../plugins/rendering_plugin/package.json | 2 +- .../plugins/ui_settings_plugin/package.json | 2 +- yarn.lock | 13 ++---- 452 files changed, 733 insertions(+), 736 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a208b4f1f40..40cce19f26d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### 🛠 Maintenance - Adding @zhongnansu as maintainer. ([#2590](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2590)) +- Upgrades TypeScript to 4.1, fixes simple errors ### 🪛 Refactoring diff --git a/examples/dashboard_embeddable_examples/public/by_value/input_editor.tsx b/examples/dashboard_embeddable_examples/public/by_value/input_editor.tsx index 917e85b9c053..d71afff51cf1 100644 --- a/examples/dashboard_embeddable_examples/public/by_value/input_editor.tsx +++ b/examples/dashboard_embeddable_examples/public/by_value/input_editor.tsx @@ -39,7 +39,7 @@ export const InputEditor = (props: { input: T; onSubmit: (value: T) => void try { JSON.parse(value); return true; - } catch (e) { + } catch (e: any) { return false; } })(); diff --git a/examples/expressions_example/public/components/basic_tab.tsx b/examples/expressions_example/public/components/basic_tab.tsx index 06005b7ca8d6..b6a37e683a9a 100644 --- a/examples/expressions_example/public/components/basic_tab.tsx +++ b/examples/expressions_example/public/components/basic_tab.tsx @@ -50,7 +50,7 @@ export function BasicTab() { setLoading(false); setResult(String(value)); }); - } catch (error) { + } catch (error: any) { setLoading(false); setResult(String(error)); } diff --git a/examples/expressions_example/public/components/playground_section.tsx b/examples/expressions_example/public/components/playground_section.tsx index 503074040f32..15fe7d13c4f4 100644 --- a/examples/expressions_example/public/components/playground_section.tsx +++ b/examples/expressions_example/public/components/playground_section.tsx @@ -67,7 +67,7 @@ export function PlaygroundSection({ setLoading(false); setResult(parsedValue); }); - } catch (error) { + } catch (error: any) { setLoading(false); setResult(String(error)); } diff --git a/examples/routing_example/public/services.ts b/examples/routing_example/public/services.ts index a122463ca771..22a4cc82ca14 100644 --- a/examples/routing_example/public/services.ts +++ b/examples/routing_example/public/services.ts @@ -51,7 +51,7 @@ export function getServices(core: CoreStart): Services { try { const response = await core.http.fetch<{ randomNumber: number }>(RANDOM_NUMBER_ROUTE_PATH); return response.randomNumber; - } catch (e) { + } catch (e: any) { return e; } }, @@ -62,7 +62,7 @@ export function getServices(core: CoreStart): Services { { query: { max } } ); return response.randomNumber; - } catch (e) { + } catch (e: any) { return e; } }, @@ -71,7 +71,7 @@ export function getServices(core: CoreStart): Services { await core.http.post(`${POST_MESSAGE_ROUTE_PATH}/${id}`, { body: JSON.stringify({ message }), }); - } catch (e) { + } catch (e: any) { return e; } }, @@ -81,7 +81,7 @@ export function getServices(core: CoreStart): Services { `${INTERNAL_GET_MESSAGE_BY_ID_ROUTE}/${id}` ); return response.message; - } catch (e) { + } catch (e: any) { return e; } }, diff --git a/examples/search_examples/public/components/app.tsx b/examples/search_examples/public/components/app.tsx index c3c106631a5e..cb0ab0ffd2f0 100644 --- a/examples/search_examples/public/components/app.tsx +++ b/examples/search_examples/public/components/app.tsx @@ -206,7 +206,7 @@ export const SearchExamplesApp = ({ }); notifications.toasts.addSuccess(`Server returned ${JSON.stringify(response)}`); - } catch (e) { + } catch (e: any) { notifications.toasts.addDanger('Failed to run search'); } }; diff --git a/package.json b/package.json index e41ae70451e7..4c99dfbcefa6 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "**/nth-check": "^2.0.1", "**/qs": "^6.10.3", "**/trim": "^0.0.3", - "**/typescript": "4.0.2", + "**/typescript": "4.1.6", "**/unset-value": "^2.0.1", "**/minimatch": "^3.0.5" }, @@ -450,7 +450,7 @@ "topojson-client": "3.0.0", "tough-cookie": "^4.0.0", "tree-kill": "^1.2.2", - "typescript": "4.0.2", + "typescript": "4.1.6", "ui-select": "0.19.8", "vega": "^5.17.3", "vega-interpreter": "npm:@amoo-miki/vega-forced-csp-compliant-interpreter@1.0.6", diff --git a/packages/osd-ace/package.json b/packages/osd-ace/package.json index 5a2f3141ddd5..2a9a35545121 100644 --- a/packages/osd-ace/package.json +++ b/packages/osd-ace/package.json @@ -15,7 +15,7 @@ "@osd/dev-utils": "1.0.0", "@osd/babel-preset": "1.0.0", "raw-loader": "^4.0.2", - "typescript": "4.0.2", + "typescript": "4.1.6", "webpack": "^4.41.5" } } diff --git a/packages/osd-analytics/package.json b/packages/osd-analytics/package.json index d460ab335a2d..a4106d97152a 100644 --- a/packages/osd-analytics/package.json +++ b/packages/osd-analytics/package.json @@ -17,6 +17,6 @@ "@babel/cli": "^7.16.0", "@osd/dev-utils": "1.0.0", "@osd/babel-preset": "1.0.0", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-analytics/src/reporter.ts b/packages/osd-analytics/src/reporter.ts index d4d7b68a25a2..284a8bfd48d9 100644 --- a/packages/osd-analytics/src/reporter.ts +++ b/packages/osd-analytics/src/reporter.ts @@ -153,7 +153,7 @@ export class Reporter { try { // await this.http(this.reportManager.report); this.flushReport(); - } catch (err) { + } catch (err: any) { this.log(`Error Sending Metrics Report ${err}`); this.retryCount = this.retryCount + 1; const versionMismatch = diff --git a/packages/osd-apm-config-loader/package.json b/packages/osd-apm-config-loader/package.json index c3c0249bd73e..c36a85ece5f7 100644 --- a/packages/osd-apm-config-loader/package.json +++ b/packages/osd-apm-config-loader/package.json @@ -17,7 +17,7 @@ "lodash": "^4.17.21" }, "devDependencies": { - "typescript": "4.0.2", + "typescript": "4.1.6", "tsd": "^0.21.0" } } diff --git a/packages/osd-apm-config-loader/src/config.ts b/packages/osd-apm-config-loader/src/config.ts index 5750bea9aa51..ef9129216b96 100644 --- a/packages/osd-apm-config-loader/src/config.ts +++ b/packages/osd-apm-config-loader/src/config.ts @@ -133,14 +133,14 @@ export class ApmConfiguration { try { const filename = join(dataPath, 'uuid'); return readFileSync(filename, 'utf-8'); - } catch (e) {} // eslint-disable-line no-empty + } catch (e: any) {} // eslint-disable-line no-empty } private getDevConfig(): ApmAgentConfig { try { const apmDevConfigPath = join(this.rootDir, 'config', 'apm.dev.js'); return require(apmDevConfigPath); - } catch (e) { + } catch (e: any) { return {}; } } @@ -167,7 +167,7 @@ export class ApmConfiguration { encoding: 'utf-8' as BufferEncoding, stdio: ['ignore', 'pipe', 'ignore'], }).trim(); - } catch (e) { + } catch (e: any) { return null; } } diff --git a/packages/osd-config-schema/package.json b/packages/osd-config-schema/package.json index 52471e29527c..ab5085c5e26a 100644 --- a/packages/osd-config-schema/package.json +++ b/packages/osd-config-schema/package.json @@ -12,7 +12,7 @@ "devDependencies": { "@osd/cross-platform": "1.0.0", "tsd": "^0.21.0", - "typescript": "4.0.2" + "typescript": "4.1.6" }, "peerDependencies": { "lodash": "^4.17.21", diff --git a/packages/osd-config-schema/src/errors/schema_error.test.ts b/packages/osd-config-schema/src/errors/schema_error.test.ts index c134c888d510..e1b91d078069 100644 --- a/packages/osd-config-schema/src/errors/schema_error.test.ts +++ b/packages/osd-config-schema/src/errors/schema_error.test.ts @@ -57,7 +57,7 @@ export const cleanStack = (stack: string) => it('includes stack', () => { try { throw new SchemaError('test'); - } catch (e) { + } catch (e: any) { expect(cleanStack(e.stack)).toMatchSnapshot(); } }); diff --git a/packages/osd-config-schema/src/internals/index.ts b/packages/osd-config-schema/src/internals/index.ts index ab37a785d477..adad4c615909 100644 --- a/packages/osd-config-schema/src/internals/index.ts +++ b/packages/osd-config-schema/src/internals/index.ts @@ -60,7 +60,7 @@ const anyCustomRule: Rules = { let validationResultMessage; try { validationResultMessage = params.validator(value); - } catch (e) { + } catch (e: any) { validationResultMessage = e.message || e; } @@ -161,7 +161,7 @@ export const internals = Joi.extend([ if (typeof value === 'number') { return new ByteSizeValue(value); } - } catch (e) { + } catch (e: any) { return this.createError('bytes.parse', { value, message: e.message }, state, options); } @@ -215,7 +215,7 @@ export const internals = Joi.extend([ if (typeof value === 'string' || typeof value === 'number') { return ensureDuration(value); } - } catch (e) { + } catch (e: any) { return this.createError('duration.parse', { value, message: e.message }, state, options); } @@ -271,7 +271,7 @@ export const internals = Joi.extend([ return parsed; } return this.createError('object.base', { value: parsed }, state, options); - } catch (e) { + } catch (e: any) { return this.createError('object.parse', { value }, state, options); } } @@ -297,7 +297,7 @@ export const internals = Joi.extend([ return new Map(Object.entries(parsed)); } return this.createError('map.base', { value: parsed }, state, options); - } catch (e) { + } catch (e: any) { return this.createError('map.parse', { value }, state, options); } } @@ -369,7 +369,7 @@ export const internals = Joi.extend([ return parsed; } return this.createError('record.base', { value: parsed }, state, options); - } catch (e) { + } catch (e: any) { return this.createError('record.parse', { value }, state, options); } } @@ -433,7 +433,7 @@ export const internals = Joi.extend([ return parsed; } return this.createError('array.base', { value: parsed }, state, options); - } catch (e) { + } catch (e: any) { return this.createError('array.parse', { value }, state, options); } } diff --git a/packages/osd-config/package.json b/packages/osd-config/package.json index 7d2f68abc8d8..eb32c7a142fc 100644 --- a/packages/osd-config/package.json +++ b/packages/osd-config/package.json @@ -24,7 +24,7 @@ "devDependencies": { "@osd/dev-utils": "1.0.0", "@osd/utility-types": "1.0.0", - "typescript": "4.0.2", + "typescript": "4.1.6", "tsd": "^0.21.0" } } diff --git a/packages/osd-cross-platform/package.json b/packages/osd-cross-platform/package.json index 1af90b00a98f..db6ce1a81da3 100644 --- a/packages/osd-cross-platform/package.json +++ b/packages/osd-cross-platform/package.json @@ -9,7 +9,7 @@ "osd:bootstrap": "yarn build" }, "devDependencies": { - "typescript": "4.0.2", + "typescript": "4.1.6", "tsd": "^0.21.0" } } diff --git a/packages/osd-cross-platform/src/path.test.ts b/packages/osd-cross-platform/src/path.test.ts index ed405298ad13..5a7f8d40e758 100644 --- a/packages/osd-cross-platform/src/path.test.ts +++ b/packages/osd-cross-platform/src/path.test.ts @@ -44,7 +44,7 @@ describe('Cross Platform', () => { // If leftover artifacts were found, get rid of them await access(tmpTestFolder); await rmdir(tmpTestFolder, { recursive: true }); - } catch (ex) { + } catch (ex: any) { // Do nothing; if `rmdir` failed, let the `mkdir` below throw the error } @@ -61,7 +61,7 @@ describe('Cross Platform', () => { afterAll(async () => { try { await rmdir(tmpTestFolder, { recursive: true }); - } catch (ex) { + } catch (ex: any) { // Do nothing } }); diff --git a/packages/osd-cross-platform/src/path.ts b/packages/osd-cross-platform/src/path.ts index d5b2befb56c1..a0bdc501a105 100644 --- a/packages/osd-cross-platform/src/path.ts +++ b/packages/osd-cross-platform/src/path.ts @@ -55,7 +55,7 @@ const getFullPathSync = (path: string) => { // Make sure we got something back if (fullName?.length > 2) return fullName; - } catch (ex) { + } catch (ex: any) { // Do nothing } @@ -80,7 +80,7 @@ const getShortPathSync = (path: string) => { // Make sure we got something back if (shortPath?.length > 2) return shortPath; - } catch (ex) { + } catch (ex: any) { // Do nothing } diff --git a/packages/osd-cross-platform/src/repo_root.ts b/packages/osd-cross-platform/src/repo_root.ts index a7ffc19a7f7c..3bd56d3736a0 100644 --- a/packages/osd-cross-platform/src/repo_root.ts +++ b/packages/osd-cross-platform/src/repo_root.ts @@ -40,7 +40,7 @@ const readOpenSearchDashboardsPkgJson = (dir: string) => { if (json?.name === 'opensearch-dashboards') { return json; } - } catch (error) { + } catch (error: any) { if (error && error.code === 'ENOENT') { return; } diff --git a/packages/osd-dev-utils/package.json b/packages/osd-dev-utils/package.json index ea433fa5e101..253767bde6c1 100644 --- a/packages/osd-dev-utils/package.json +++ b/packages/osd-dev-utils/package.json @@ -37,6 +37,6 @@ "@osd/expect": "1.0.0", "@types/vinyl": "^2.0.4", "chance": "1.0.18", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts b/packages/osd-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts index d7a82b7c8024..e77ffadba5f4 100644 --- a/packages/osd-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts +++ b/packages/osd-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts @@ -140,7 +140,7 @@ export class CiStatsReporter { }); return; - } catch (error) { + } catch (error: any) { if (!error?.request) { // not an axios error, must be a usage error that we should notify user about throw error; diff --git a/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts b/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts index effa5da6dd7e..df93d50ff5c1 100644 --- a/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts +++ b/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts @@ -130,7 +130,7 @@ export class OsdClientRequester { }); return response; - } catch (error) { + } catch (error: any) { const conflictOnGet = isConcliftOnGetError(error); const requestedRetries = options.retries !== undefined; const failedToGetResponse = isAxiosRequestError(error); diff --git a/packages/osd-dev-utils/src/precommit_hook/cli.ts b/packages/osd-dev-utils/src/precommit_hook/cli.ts index 3da4231bafa1..b605850591a3 100644 --- a/packages/osd-dev-utils/src/precommit_hook/cli.ts +++ b/packages/osd-dev-utils/src/precommit_hook/cli.ts @@ -60,7 +60,7 @@ run( await writeFileAsync(installPath, SCRIPT_SOURCE); await chmodAsync(installPath, 0o755); log.success(`OpenSearch Dashboards pre-commit git hook was installed successfully.`); - } catch (e) { + } catch (e: any) { if (isFailError(e)) { return; } diff --git a/packages/osd-dev-utils/src/proc_runner/proc.ts b/packages/osd-dev-utils/src/proc_runner/proc.ts index 1de472df40b2..a23ca80fe368 100644 --- a/packages/osd-dev-utils/src/proc_runner/proc.ts +++ b/packages/osd-dev-utils/src/proc_runner/proc.ts @@ -65,7 +65,7 @@ async function withTimeout( attempt(), new Promise((_, reject) => setTimeout(() => reject(TIMEOUT), ms)), ]); - } catch (error) { + } catch (error: any) { if (error === TIMEOUT) { await onTimeout(); } else { @@ -88,7 +88,7 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) { if (!statSync(cwd).isDirectory()) { throw new Error(`cwd "${cwd}" exists but is not a directory`); } - } catch (err) { + } catch (err: any) { if (err.code === 'ENOENT') { throw new Error(`cwd "${cwd}" does not exist`); } @@ -169,7 +169,7 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) { async () => { try { await outcomePromise; - } catch (error) { + } catch (error: any) { // ignore } }, diff --git a/packages/osd-dev-utils/src/run/cleanup.ts b/packages/osd-dev-utils/src/run/cleanup.ts index 17e546d7a2bb..ec58ac6583a8 100644 --- a/packages/osd-dev-utils/src/run/cleanup.ts +++ b/packages/osd-dev-utils/src/run/cleanup.ts @@ -77,7 +77,7 @@ export class Cleanup { for (const task of tasks) { try { task(); - } catch (error) { + } catch (error: any) { this.onError(error); } } diff --git a/packages/osd-dev-utils/src/run/run.ts b/packages/osd-dev-utils/src/run/run.ts index 8fcf8e7ef83f..c404036e1ac4 100644 --- a/packages/osd-dev-utils/src/run/run.ts +++ b/packages/osd-dev-utils/src/run/run.ts @@ -89,7 +89,7 @@ export async function run(fn: RunFn, options: RunOptions = {}) { addCleanupTask: cleanup.add.bind(cleanup), }); }); - } catch (error) { + } catch (error: any) { cleanup.execute(error); // process.exitCode is set by `cleanup` when necessary process.exit(); diff --git a/packages/osd-dev-utils/src/run/run_with_commands.ts b/packages/osd-dev-utils/src/run/run_with_commands.ts index 9f85ed4b7fc9..6a6b708202ea 100644 --- a/packages/osd-dev-utils/src/run/run_with_commands.ts +++ b/packages/osd-dev-utils/src/run/run_with_commands.ts @@ -143,7 +143,7 @@ export class RunWithCommands { await command.run(extendedContext); }); - } catch (error) { + } catch (error: any) { cleanup.execute(error); // exitCode is set by `cleanup` when necessary process.exit(); diff --git a/packages/osd-i18n/package.json b/packages/osd-i18n/package.json index 98b3f9bbde1d..a7ccc5f5e791 100644 --- a/packages/osd-i18n/package.json +++ b/packages/osd-i18n/package.json @@ -21,7 +21,7 @@ "del": "^6.1.1", "getopts": "^2.2.5", "supports-color": "^7.0.0", - "typescript": "4.0.2" + "typescript": "4.1.6" }, "dependencies": { "intl-format-cache": "^2.1.0", diff --git a/packages/osd-i18n/src/core/i18n.ts b/packages/osd-i18n/src/core/i18n.ts index 3268fae5079f..ff054c332f1a 100644 --- a/packages/osd-i18n/src/core/i18n.ts +++ b/packages/osd-i18n/src/core/i18n.ts @@ -210,7 +210,7 @@ export function translate(id: string, { values = {}, defaultMessage }: Translate return shouldUsePseudoLocale ? translateUsingPseudoLocale(formattedMessage) : formattedMessage; - } catch (e) { + } catch (e: any) { throw new Error( `[I18n] Error formatting message: "${id}" for locale: "${getLocale()}".\n${e}` ); @@ -221,7 +221,7 @@ export function translate(id: string, { values = {}, defaultMessage }: Translate const msg = getMessageFormat(defaultMessage, getDefaultLocale(), getFormats()); return msg.format(values); - } catch (e) { + } catch (e: any) { throw new Error(`[I18n] Error formatting the default message for: "${id}".\n${e}`); } } diff --git a/packages/osd-logging/package.json b/packages/osd-logging/package.json index 1d8374ced5ee..8e381f6ca34e 100644 --- a/packages/osd-logging/package.json +++ b/packages/osd-logging/package.json @@ -13,6 +13,6 @@ "@osd/std": "1.0.0" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-monaco/package.json b/packages/osd-monaco/package.json index e937b1e8f60b..6a07e543ae88 100644 --- a/packages/osd-monaco/package.json +++ b/packages/osd-monaco/package.json @@ -20,7 +20,7 @@ "del": "^6.1.1", "raw-loader": "^4.0.2", "supports-color": "^7.0.0", - "typescript": "4.0.2", + "typescript": "4.1.6", "webpack": "^4.41.5", "webpack-cli": "^4.9.2" } diff --git a/packages/osd-monaco/src/xjson/grammar.ts b/packages/osd-monaco/src/xjson/grammar.ts index dba2367acd7a..101b75fa6150 100644 --- a/packages/osd-monaco/src/xjson/grammar.ts +++ b/packages/osd-monaco/src/xjson/grammar.ts @@ -225,7 +225,7 @@ export const createParser = () => { try { value(); white(); - } catch (e) { + } catch (e: any) { errored = true; annos.push({ type: AnnoTypes.error, at: e.at - 1, text: e.message }); } diff --git a/packages/osd-opensearch-archiver/src/cli.ts b/packages/osd-opensearch-archiver/src/cli.ts index 39dbbb264cd7..24fb98923e02 100644 --- a/packages/osd-opensearch-archiver/src/cli.ts +++ b/packages/osd-opensearch-archiver/src/cli.ts @@ -158,7 +158,7 @@ export function runCli() { if (typeof query === 'string' && query.length > 0) { try { parsedQuery = JSON.parse(query); - } catch (err) { + } catch (err: any) { throw createFlagError('--query should be valid JSON'); } } @@ -239,7 +239,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/packages/osd-opensearch-archiver/src/lib/archives/parse.test.ts b/packages/osd-opensearch-archiver/src/lib/archives/parse.test.ts index 9f574a1aacff..57855a1acae7 100644 --- a/packages/osd-opensearch-archiver/src/lib/archives/parse.test.ts +++ b/packages/osd-opensearch-archiver/src/lib/archives/parse.test.ts @@ -119,7 +119,7 @@ describe('opensearchArchiver createParseArchiveStreams', () => { createConcatStream([]), ] as [Readable, ...Writable[]]); throw new Error('should have failed'); - } catch (err) { + } catch (err: any) { const { message } = err as Error; expect(message).to.contain('Unexpected number'); } @@ -183,7 +183,7 @@ describe('opensearchArchiver createParseArchiveStreams', () => { createConcatStream([]), ] as [Readable, ...Writable[]]); throw new Error('should have failed'); - } catch (err) { + } catch (err: any) { const { message } = err as Error; expect(message).to.contain('incorrect header check'); } diff --git a/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts index 6949e2b4d4ff..e3aae20de570 100644 --- a/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts @@ -98,7 +98,7 @@ export function createGenerateDocRecordsStream({ } callback(undefined); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.test.ts b/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.test.ts index 00b9e22660ca..3088f193a9e6 100644 --- a/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.test.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.test.ts @@ -200,7 +200,7 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => { createIndexDocRecordsStream(client, stats, progress), ]); throw new Error('expected stream to emit error'); - } catch (err) { + } catch (err: any) { const { message } = err as Error; expect(message).to.match(/"forcedError":\s*true/); } diff --git a/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts index d1ba68f7bf05..c051562760c8 100644 --- a/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts @@ -73,7 +73,7 @@ export function createIndexDocRecordsStream( await indexDocs([record.value]); progress.addToComplete(1); callback(null); - } catch (err) { + } catch (err: any) { callback(err); } }, @@ -83,7 +83,7 @@ export function createIndexDocRecordsStream( await indexDocs(chunks.map(({ chunk: record }) => record.value)); progress.addToComplete(chunks.length); callback(null); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts index 6154f0382a96..2e85eb26634a 100644 --- a/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts @@ -97,7 +97,7 @@ export function createCreateIndexStream({ } as any); stats.createdIndex(index, { settings }); - } catch (err) { + } catch (err: any) { if ( err?.body?.error?.reason?.includes('index exists with the same name as the alias') && attemptNumber < 3 @@ -150,7 +150,7 @@ export function createCreateIndexStream({ } callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts b/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts index ee8fe10d8d0b..b1b475cc1ad8 100644 --- a/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts @@ -57,7 +57,7 @@ export async function deleteIndex(options: { const indexToDelete = indicesToDelete[i]; stats.deletedIndex(indexToDelete); } - } catch (error) { + } catch (error: any) { if (retryIfSnapshottingCount > 0 && isDeleteWhileSnapshotInProgressError(error)) { stats.waitingForInProgressSnapshot(index); await waitForSnapshotCompletion(client, index, log); diff --git a/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts index b728aa35757b..757be0602a14 100644 --- a/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts @@ -64,7 +64,7 @@ export function createDeleteIndexStream( this.push(record); } callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts index f682af3d8598..91eeb250922f 100644 --- a/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts @@ -75,7 +75,7 @@ export function createGenerateIndexRecordsStream(client: Client, stats: Stats) { } callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/stats.test.ts b/packages/osd-opensearch-archiver/src/lib/stats.test.ts index da7c6d240d0d..129f9b076360 100644 --- a/packages/osd-opensearch-archiver/src/lib/stats.test.ts +++ b/packages/osd-opensearch-archiver/src/lib/stats.test.ts @@ -64,7 +64,7 @@ function assertDeepClones(a: any, b: any) { path.pop(); }); })(a, b); - } catch (err) { + } catch (err: any) { const { stack } = err as Error; throw new Error( `Expected a and b to be deep clones of each other, error at:\n\n` + diff --git a/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts index 50d86097fa72..2ad944cca6cf 100644 --- a/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts @@ -64,7 +64,7 @@ export function createIntersperseStream(intersperseChunk: any) { this.push(chunk); callback(undefined); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts index cbe0fbbe8bf8..1385d0a907e9 100644 --- a/packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts @@ -39,7 +39,7 @@ export function createMapStream(fn: (chunk: any, i: number) => T | Prom try { this.push(await fn(value, i++)); done(); - } catch (err) { + } catch (err: any) { done(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts index 486018ee024d..89756e09ddcd 100644 --- a/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts @@ -71,7 +71,7 @@ export function createReduceStream( } callback(); - } catch (err) { + } catch (err: any) { failed = true; callback(err); } diff --git a/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts index ab3f0c87adb6..cc84f8a276bd 100644 --- a/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts @@ -79,7 +79,7 @@ export function createReplaceStream(toReplace: string, replacement: string) { } done(); - } catch (err) { + } catch (err: any) { done(err); } }, diff --git a/packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts index 91af2f6e0526..cb89d06b3305 100644 --- a/packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts @@ -64,7 +64,7 @@ export function createSplitStream(splitChunk: string) { unsplitBuffer = toSplit; callback(undefined); - } catch (err) { + } catch (err: any) { callback(err); } }, @@ -74,7 +74,7 @@ export function createSplitStream(splitChunk: string) { this.push(unsplitBuffer.toString('utf8')); callback(undefined); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/packages/osd-optimizer/src/common/bundle.ts b/packages/osd-optimizer/src/common/bundle.ts index fbc03c55b03a..9bab6fbc499f 100644 --- a/packages/osd-optimizer/src/common/bundle.ts +++ b/packages/osd-optimizer/src/common/bundle.ts @@ -143,7 +143,7 @@ export class Bundle { let json: string; try { json = Fs.readFileSync(this.manifestPath, 'utf8'); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } @@ -154,7 +154,7 @@ export class Bundle { let parsedManifest: { requiredPlugins?: string[]; requiredBundles?: string[] }; try { parsedManifest = JSON.parse(json); - } catch (error) { + } catch (error: any) { throw new Error( `unable to parse manifest at [${this.manifestPath}], error: [${error.message}]` ); @@ -256,7 +256,7 @@ export function parseBundles(json: string) { }); } ); - } catch (error) { + } catch (error: any) { throw new Error(`unable to parse bundles: ${error.message}`); } } diff --git a/packages/osd-optimizer/src/common/bundle_cache.ts b/packages/osd-optimizer/src/common/bundle_cache.ts index 43f55f91b98c..bc209ec525f5 100644 --- a/packages/osd-optimizer/src/common/bundle_cache.ts +++ b/packages/osd-optimizer/src/common/bundle_cache.ts @@ -61,7 +61,7 @@ export class BundleCache { if (this.path) { json = Fs.readFileSync(this.path, 'utf8'); } - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } @@ -70,7 +70,7 @@ export class BundleCache { let partialCache: Partial; try { partialCache = JSON.parse(json || DEFAULT_STATE_JSON); - } catch (error) { + } catch (error: any) { partialCache = {}; } @@ -122,7 +122,7 @@ export class BundleCache { if (this.path) { try { Fs.unlinkSync(this.path); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } diff --git a/packages/osd-optimizer/src/common/bundle_refs.ts b/packages/osd-optimizer/src/common/bundle_refs.ts index 32630473826f..98f6f4718ca5 100644 --- a/packages/osd-optimizer/src/common/bundle_refs.ts +++ b/packages/osd-optimizer/src/common/bundle_refs.ts @@ -71,7 +71,7 @@ export class BundleRefs { let spec; try { spec = JSON.parse(json); - } catch (error) { + } catch (error: any) { throw new Error('`bundleRefs` spec must be valid JSON'); } diff --git a/packages/osd-optimizer/src/common/event_stream_helpers.ts b/packages/osd-optimizer/src/common/event_stream_helpers.ts index 6b089294e478..4ff16323e0f2 100644 --- a/packages/osd-optimizer/src/common/event_stream_helpers.ts +++ b/packages/osd-optimizer/src/common/event_stream_helpers.ts @@ -88,7 +88,7 @@ export const summarizeEventStream = ( if (eventStreamComplete) { subscriber.complete(); } - } catch (error) { + } catch (error: any) { subscriber.error(error); } finally { processingEventBuffer = false; diff --git a/packages/osd-optimizer/src/common/worker_config.ts b/packages/osd-optimizer/src/common/worker_config.ts index fe50b51b0e0b..4563018b5f71 100644 --- a/packages/osd-optimizer/src/common/worker_config.ts +++ b/packages/osd-optimizer/src/common/worker_config.ts @@ -105,7 +105,7 @@ export function parseWorkerConfig(json: string): WorkerConfig { browserslistEnv, themeTags: themes, }; - } catch (error) { + } catch (error: any) { throw new Error(`unable to parse worker config: ${error.message}`); } } diff --git a/packages/osd-optimizer/src/limits.ts b/packages/osd-optimizer/src/limits.ts index 86b186930275..36834bad357a 100644 --- a/packages/osd-optimizer/src/limits.ts +++ b/packages/osd-optimizer/src/limits.ts @@ -45,7 +45,7 @@ export function readLimits(): Limits { let yaml; try { yaml = Fs.readFileSync(LIMITS_PATH, 'utf8'); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } diff --git a/packages/osd-optimizer/src/node/cache.ts b/packages/osd-optimizer/src/node/cache.ts index e60038102fb5..d07ef1d114b3 100644 --- a/packages/osd-optimizer/src/node/cache.ts +++ b/packages/osd-optimizer/src/node/cache.ts @@ -167,7 +167,7 @@ export class Cache { const value = db.get(key); this.debug(value === undefined ? 'MISS' : 'HIT', db, key); return value; - } catch (error) { + } catch (error: any) { this.logError('GET', db, key, error); } } @@ -176,7 +176,7 @@ export class Cache { try { await db.put(key, value); this.debug('PUT', db, key); - } catch (error) { + } catch (error: any) { this.logError('PUT', db, key, error); } } diff --git a/packages/osd-optimizer/src/node/node_auto_tranpilation.ts b/packages/osd-optimizer/src/node/node_auto_tranpilation.ts index 87fcde1ce9d3..f8f814f8c1a0 100644 --- a/packages/osd-optimizer/src/node/node_auto_tranpilation.ts +++ b/packages/osd-optimizer/src/node/node_auto_tranpilation.ts @@ -128,7 +128,7 @@ function compile(cache: Cache, source: string, path: string) { }); return result.code; - } catch (error) { + } catch (error: any) { throw error; } } diff --git a/packages/osd-optimizer/src/optimizer/cache_keys.ts b/packages/osd-optimizer/src/optimizer/cache_keys.ts index 16efdea4888b..0e1ad635c101 100644 --- a/packages/osd-optimizer/src/optimizer/cache_keys.ts +++ b/packages/osd-optimizer/src/optimizer/cache_keys.ts @@ -156,7 +156,7 @@ async function getLastCommit() { async function getBootstrapCacheKey() { try { return await readFile(resolve(OPTIMIZER_DIR, 'target/.bootstrap-cache'), { encoding: 'utf8' }); - } catch (error) { + } catch (error: any) { if (error?.code !== 'ENOENT') { throw error; } diff --git a/packages/osd-optimizer/src/optimizer/optimizer_config.ts b/packages/osd-optimizer/src/optimizer/optimizer_config.ts index c9a760dc2bfa..f8ef9a25f103 100644 --- a/packages/osd-optimizer/src/optimizer/optimizer_config.ts +++ b/packages/osd-optimizer/src/optimizer/optimizer_config.ts @@ -65,7 +65,7 @@ function pickMaxWorkerCount(dist: boolean) { function omit(obj: T, keys: K[]): Omit { const result: any = {}; - for (const [key, value] of Object.entries(obj) as any) { + for (const [key, value] of Object.entries(obj || {}) as any) { if (!keys.includes(key)) { result[key] = value; } diff --git a/packages/osd-optimizer/src/run_optimizer.ts b/packages/osd-optimizer/src/run_optimizer.ts index a91ff5042318..19550b9a3406 100644 --- a/packages/osd-optimizer/src/run_optimizer.ts +++ b/packages/osd-optimizer/src/run_optimizer.ts @@ -54,7 +54,7 @@ export function runOptimizer(config: OptimizerConfig) { if (process.platform === 'darwin') { try { require.resolve('fsevents'); - } catch (error) { + } catch (error: any) { if (error.code === 'MODULE_NOT_FOUND') { throw new Error( '`fsevents` module is not installed, most likely because you need to follow the instructions at https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md and re-bootstrap OpenSearch Dashboards' diff --git a/packages/osd-optimizer/src/worker/run_compilers.ts b/packages/osd-optimizer/src/worker/run_compilers.ts index 4cd55b5ad07c..0d0da461f304 100644 --- a/packages/osd-optimizer/src/worker/run_compilers.ts +++ b/packages/osd-optimizer/src/worker/run_compilers.ts @@ -182,7 +182,7 @@ const observeCompiler = ( files.map((path): [string, number | undefined] => { try { return [path, compiler.inputFileSystem.statSync(path)?.mtimeMs]; - } catch (error) { + } catch (error: any) { if (error?.code === 'ENOENT') { return [path, undefined]; } diff --git a/packages/osd-plugin-helpers/package.json b/packages/osd-plugin-helpers/package.json index 7ee45578a63b..8defb9fdd119 100644 --- a/packages/osd-plugin-helpers/package.json +++ b/packages/osd-plugin-helpers/package.json @@ -31,6 +31,6 @@ "@types/gulp-zip": "^4.0.1", "@types/inquirer": "^7.3.1", "extract-zip": "^2.0.1", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-plugin-helpers/src/cli.ts b/packages/osd-plugin-helpers/src/cli.ts index c4b1a83fedaf..4a4d89109879 100644 --- a/packages/osd-plugin-helpers/src/cli.ts +++ b/packages/osd-plugin-helpers/src/cli.ts @@ -159,21 +159,21 @@ export function runCli() { let dashboardsPackage; try { dashboardsPackage = await import(Path.join(PROCESS_WORKING_DIR, '../../package.json')); - } catch (ex) { + } catch (ex: any) { throw createFailError(`Unable to parse the OpenSearch Dashboards' package.json file`); } let pluginPackage; try { pluginPackage = await import(Path.join(PROCESS_WORKING_DIR, 'package.json')); - } catch (ex) { + } catch (ex: any) { throw createFailError(`Unable to parse the plugin's package.json file`); } let manifestFile; try { manifestFile = await import(Path.join(PROCESS_WORKING_DIR, 'opensearch_dashboards.json')); - } catch (ex) { + } catch (ex: any) { throw createFailError(`Unable to parse the plugin's opensearch_dashboards.json file`); } diff --git a/packages/osd-plugin-helpers/src/config.ts b/packages/osd-plugin-helpers/src/config.ts index 22fc08e4f41a..73dd18761067 100644 --- a/packages/osd-plugin-helpers/src/config.ts +++ b/packages/osd-plugin-helpers/src/config.ts @@ -82,7 +82,7 @@ export async function loadConfig(log: ToolingLog, plugin: Plugin): Promise boolean) { try { return block(await lstat(path)); - } catch (e) { + } catch (e: any) { if (e.code === 'ENOENT') { return false; } @@ -108,7 +108,7 @@ async function forceCreate(src: string, dest: string, type: string) { try { // If something exists at `dest` we need to remove it first. await unlink(dest); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } diff --git a/packages/osd-pm/src/utils/parallelize.ts b/packages/osd-pm/src/utils/parallelize.ts index 6853b936e7cb..2f37ea9d8c07 100644 --- a/packages/osd-pm/src/utils/parallelize.ts +++ b/packages/osd-pm/src/utils/parallelize.ts @@ -61,7 +61,7 @@ export async function parallelize(items: T[], fn: (item: T) => Promise, // completed all the work. resolve(); } - } catch (error) { + } catch (error: any) { reject(error); } } diff --git a/packages/osd-pm/src/utils/scripts.ts b/packages/osd-pm/src/utils/scripts.ts index cbb49875c021..c70f6b51fec2 100644 --- a/packages/osd-pm/src/utils/scripts.ts +++ b/packages/osd-pm/src/utils/scripts.ts @@ -98,7 +98,7 @@ export async function yarnWorkspacesInfo(directory: string): Promise } throw new Error('unable to read yarn.lock file, please run `yarn osd bootstrap`'); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } diff --git a/packages/osd-std/package.json b/packages/osd-std/package.json index 93bf1abb81d9..6bdbbc9c1265 100644 --- a/packages/osd-std/package.json +++ b/packages/osd-std/package.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@osd/utility-types": "1.0.0", - "typescript": "4.0.2", + "typescript": "4.1.6", "tsd": "^0.21.0" } } diff --git a/packages/osd-telemetry-tools/package.json b/packages/osd-telemetry-tools/package.json index b697f7012df3..13fd4d9640af 100644 --- a/packages/osd-telemetry-tools/package.json +++ b/packages/osd-telemetry-tools/package.json @@ -20,6 +20,6 @@ "normalize-path": "^3.0.0", "@types/lodash": "^4.14.170", "moment": "^2.24.0", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-telemetry-tools/src/cli/run_telemetry_check.ts b/packages/osd-telemetry-tools/src/cli/run_telemetry_check.ts index 172278261e00..30c0b6f436de 100644 --- a/packages/osd-telemetry-tools/src/cli/run_telemetry_check.ts +++ b/packages/osd-telemetry-tools/src/cli/run_telemetry_check.ts @@ -131,7 +131,7 @@ export function runTelemetryCheck() { try { const context = createTaskContext(); await list.run(context); - } catch (error) { + } catch (error: any) { process.exitCode = 1; if (error instanceof ErrorReporter) { error.errors.forEach((e: string | Error) => log.error(e)); diff --git a/packages/osd-telemetry-tools/src/cli/run_telemetry_extract.ts b/packages/osd-telemetry-tools/src/cli/run_telemetry_extract.ts index fe74ffd4b838..f995217eb9d6 100644 --- a/packages/osd-telemetry-tools/src/cli/run_telemetry_extract.ts +++ b/packages/osd-telemetry-tools/src/cli/run_telemetry_extract.ts @@ -65,7 +65,7 @@ export function runTelemetryExtract() { try { const context = createTaskContext(); await list.run(context); - } catch (error) { + } catch (error: any) { process.exitCode = 1; if (error instanceof ErrorReporter) { error.errors.forEach((e: string | Error) => log.error(e)); diff --git a/packages/osd-telemetry-tools/src/tools/check_collector_integrity.ts b/packages/osd-telemetry-tools/src/tools/check_collector_integrity.ts index a6741c20d8e4..14d4082e1eda 100644 --- a/packages/osd-telemetry-tools/src/tools/check_collector_integrity.ts +++ b/packages/osd-telemetry-tools/src/tools/check_collector_integrity.ts @@ -61,7 +61,7 @@ export function checkCompatibleTypeDescriptor( key = key.replace(/'/g, ''); try { acc[key] = kindToDescriptorName(type); - } catch (err) { + } catch (err: any) { throw Error(`Unrecognized type (${key}: ${type}) in ${collectorPath}`); } return acc; @@ -76,7 +76,7 @@ export function checkCompatibleTypeDescriptor( key = key.replace(/'/g, ''); try { acc[key.replace(/.type$/, '.kind')] = compatibleSchemaTypes(type as any); - } catch (err) { + } catch (err: any) { throw Error(`Unrecognized type (${key}: ${type}) in ${collectorPath}`); } return acc; @@ -100,7 +100,7 @@ export function checkCompatibleTypeDescriptor( const expectedDescriptorType = JSON.stringify(transformedMappingKinds[key], null, 2); const actualDescriptorType = JSON.stringify(typeDescriptorKinds[key], null, 2); return `incompatible Type key (${collectorDetails.fetch.typeName}.${interfaceKey}): expected (${expectedDescriptorType}) got (${actualDescriptorType}).`; - } catch (err) { + } catch (err: any) { throw Error(`Error converting ${key} in ${collectorPath}.\n${err}`); } }), diff --git a/packages/osd-telemetry-tools/src/tools/tasks/parse_configs_task.ts b/packages/osd-telemetry-tools/src/tools/tasks/parse_configs_task.ts index 2ea8046f83cb..a0510cb88972 100644 --- a/packages/osd-telemetry-tools/src/tools/tasks/parse_configs_task.ts +++ b/packages/osd-telemetry-tools/src/tools/tasks/parse_configs_task.ts @@ -44,7 +44,7 @@ export function parseConfigsTask() { configs.forEach((config) => { context.roots.push({ config }); }); - } catch (err) { + } catch (err: any) { const { reporter } = context; const reporterWithContext = reporter.withContext({ name: configRoot }); reporterWithContext.report(err); diff --git a/packages/osd-telemetry-tools/src/tools/ts_parser.ts b/packages/osd-telemetry-tools/src/tools/ts_parser.ts index 31940dcfdfd3..c8000909bc55 100644 --- a/packages/osd-telemetry-tools/src/tools/ts_parser.ts +++ b/packages/osd-telemetry-tools/src/tools/ts_parser.ts @@ -212,7 +212,7 @@ export function* parseUsageCollection( try { const collectorDetails = extractCollectorDetails(node, program, sourceFile); yield [relativePath, collectorDetails]; - } catch (err) { + } catch (err: any) { throw createFailError(`Error extracting collector in ${relativePath}\n${err}`); } } diff --git a/packages/osd-test/src/failed_tests_reporter/github_api.ts b/packages/osd-test/src/failed_tests_reporter/github_api.ts index c384d56eb104..bc5bfa65b83c 100644 --- a/packages/osd-test/src/failed_tests_reporter/github_api.ts +++ b/packages/osd-test/src/failed_tests_reporter/github_api.ts @@ -228,7 +228,7 @@ export class GithubApi { try { return await this.x.request(options); - } catch (error) { + } catch (error: any) { const unableToReachGithub = isAxiosRequestError(error); const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500; const errorResponseLog = diff --git a/packages/osd-test/src/functional_test_runner/cli.ts b/packages/osd-test/src/functional_test_runner/cli.ts index 382962744355..5d3a0ef6b71a 100644 --- a/packages/osd-test/src/functional_test_runner/cli.ts +++ b/packages/osd-test/src/functional_test_runner/cli.ts @@ -109,7 +109,7 @@ export function runFtrCli() { const failureCount = await functionalTestRunner.run(); process.exitCode = failureCount ? 1 : 0; } - } catch (err) { + } catch (err: any) { await teardown(err); } finally { await teardown(); diff --git a/packages/osd-test/src/functional_test_runner/functional_test_runner.ts b/packages/osd-test/src/functional_test_runner/functional_test_runner.ts index 9c274ca9ba2a..4921f1eee2a1 100644 --- a/packages/osd-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/osd-test/src/functional_test_runner/functional_test_runner.ts @@ -164,7 +164,7 @@ export class FunctionalTestRunner { } finally { try { await this.close(); - } catch (closeError) { + } catch (closeError: any) { if (runErrorOccurred) { this.log.error('failed to close functional_test_runner'); this.log.error(closeError); diff --git a/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.test.ts b/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.test.ts index adaae7d2beba..3bb67c836277 100644 --- a/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.test.ts +++ b/packages/osd-test/src/functional_test_runner/lib/config/read_config_file.test.ts @@ -62,7 +62,7 @@ describe('readConfigFile()', () => { try { await readConfigFile(log, require.resolve('./fixtures/config.invalid')); throw new Error('expected readConfigFile() to fail'); - } catch (err) { + } catch (err: any) { const { message } = err as Error; expect(message).to.match(/"foo"/); } diff --git a/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts b/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts index 954740ca24ff..43a29b7af7e9 100644 --- a/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts +++ b/packages/osd-test/src/functional_test_runner/lib/docker_servers/docker_servers_service.ts @@ -98,7 +98,7 @@ export class DockerServersService { const res = await execa('docker', dockerArgs); return res.stdout.trim(); - } catch (error) { + } catch (error: any) { if (error?.exitCode === 125 && error?.message.includes('port is already allocated')) { throw new Error(` [docker:${server.name}] Another process is already listening on port ${server.port}. @@ -140,7 +140,7 @@ export class DockerServersService { if (!process.env.CI) { execa.sync('docker', ['rm', containerId]); } - } catch (error) { + } catch (error: any) { if ( error.message.includes(`Container ${containerId} is not running`) || error.message.includes(`No such container: ${containerId}`) diff --git a/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts index 02106a4b1dd1..10cbc9a5a327 100644 --- a/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts +++ b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts @@ -87,7 +87,7 @@ export class LifecyclePhase { await fn(...args); } catch (_error) { if (!error) { - error = _error; + error = _error || undefined; } } }) diff --git a/packages/osd-test/src/functional_test_runner/lib/load_tracer.ts b/packages/osd-test/src/functional_test_runner/lib/load_tracer.ts index a3d2d523210e..1deef5594a18 100644 --- a/packages/osd-test/src/functional_test_runner/lib/load_tracer.ts +++ b/packages/osd-test/src/functional_test_runner/lib/load_tracer.ts @@ -68,7 +68,7 @@ export function loadTracer(ident: any, description: string, load: () => Promise< try { globalLoadPath.unshift({ ident, description }); return load(); - } catch (err) { + } catch (err: any) { if (errorsFromLoadTracer.has(err)) { throw err; } diff --git a/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts b/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts index aa38548c4ffc..bff6d61d13a6 100644 --- a/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts +++ b/packages/osd-test/src/functional_test_runner/lib/providers/provider_collection.ts @@ -66,7 +66,7 @@ export class ProviderCollection { if (isAsyncInstance(instance)) { await instance.init(); } - } catch (err) { + } catch (err: any) { this.log.warning('Failure loading service %j', name); this.log.error(err); asyncInitFailures.push(name); diff --git a/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts b/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts index efadee5e5b10..2c57796da805 100644 --- a/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts +++ b/packages/osd-test/src/functional_test_runner/lib/providers/verbose_instance.ts @@ -74,7 +74,7 @@ export function createVerboseInstance( result = { returned: value.apply(this, args), }; - } catch (error) { + } catch (error: any) { result = { returned: undefined, thrown: error, diff --git a/packages/osd-utils/package.json b/packages/osd-utils/package.json index 1d632cffbf69..2c89be8635d5 100644 --- a/packages/osd-utils/package.json +++ b/packages/osd-utils/package.json @@ -15,6 +15,6 @@ "load-json-file": "^6.2.0" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/packages/osd-utils/src/path/index.ts b/packages/osd-utils/src/path/index.ts index ac4c40b0b606..beeccb8a51e0 100644 --- a/packages/osd-utils/src/path/index.ts +++ b/packages/osd-utils/src/path/index.ts @@ -61,7 +61,7 @@ function findFile(paths: string[]) { try { accessSync(configPath, constants.R_OK); return true; - } catch (e) { + } catch (e: any) { // Check the next path } }); diff --git a/src/cli/serve/integration_tests/reload_logging_config.test.ts b/src/cli/serve/integration_tests/reload_logging_config.test.ts index fb3c63ffc71d..81c481b65ec0 100644 --- a/src/cli/serve/integration_tests/reload_logging_config.test.ts +++ b/src/cli/serve/integration_tests/reload_logging_config.test.ts @@ -74,7 +74,7 @@ function watchFileUntil(path: string, matcher: RegExp, timeout: number) { Fs.unwatchFile(path); resolve(contents); } - } catch (e) { + } catch (e: any) { // noop } }); @@ -133,7 +133,7 @@ describe('Server logging configuration', function () { '--verbose', ]); - const message$ = Rx.fromEvent(child.stdout, 'data').pipe( + const message$ = Rx.fromEvent(child.stdout!, 'data').pipe( map((messages) => String(messages).split('\n').filter(Boolean)) ); @@ -204,7 +204,7 @@ describe('Server logging configuration', function () { configFilePath, ]); - const message$ = Rx.fromEvent(child.stdout, 'data').pipe( + const message$ = Rx.fromEvent(child.stdout!, 'data').pipe( map((messages) => String(messages).split('\n').filter(Boolean)) ); diff --git a/src/core/public/application/application_service.test.ts b/src/core/public/application/application_service.test.ts index c03afbba2767..691ba64cf00a 100644 --- a/src/core/public/application/application_service.test.ts +++ b/src/core/public/application/application_service.test.ts @@ -708,7 +708,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 1b659c0dec5f..9d53d99c9d8c 100644 --- a/src/core/public/application/integration_tests/application_service.test.tsx +++ b/src/core/public/application/integration_tests/application_service.test.tsx @@ -77,7 +77,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -111,7 +111,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -453,7 +453,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -491,7 +491,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 e9e2caed02e0..3e658fa25665 100644 --- a/src/core/public/application/ui/app_container.test.tsx +++ b/src/core/public/application/ui/app_container.test.tsx @@ -50,7 +50,7 @@ describe('AppContainer', () => { }); const flushPromises = async () => { - await new Promise(async (resolve) => { + await new Promise(async (resolve) => { setImmediate(() => resolve()); }); }; diff --git a/src/core/public/application/ui/app_container.tsx b/src/core/public/application/ui/app_container.tsx index b7d0619a0f9f..763af4588fa3 100644 --- a/src/core/public/application/ui/app_container.tsx +++ b/src/core/public/application/ui/app_container.tsx @@ -100,7 +100,7 @@ export const AppContainer: FunctionComponent = ({ onAppLeave: (handler) => setAppLeaveHandler(appId, handler), setHeaderActionMenu: (menuMount) => setAppActionMenu(appId, menuMount), })) || null; - } catch (e) { + } catch (e: any) { // TODO: add error UI // eslint-disable-next-line no-console console.error(e); diff --git a/src/core/public/chrome/ui/header/header_action_menu.tsx b/src/core/public/chrome/ui/header/header_action_menu.tsx index f45a2ac39e1e..6a441eef8db1 100644 --- a/src/core/public/chrome/ui/header/header_action_menu.tsx +++ b/src/core/public/chrome/ui/header/header_action_menu.tsx @@ -63,7 +63,7 @@ export const HeaderActionMenu: FC = ({ actionMenu$ }) => if (mounter.mount && elementRef.current) { try { unmountRef.current = mounter.mount(elementRef.current); - } catch (e) { + } catch (e: any) { // TODO: use client-side logger when feature is implemented // eslint-disable-next-line no-console console.error(e); diff --git a/src/core/public/core_app/status/lib/load_status.ts b/src/core/public/core_app/status/lib/load_status.ts index cf388ef22088..1c2cf26b9b24 100644 --- a/src/core/public/core_app/status/lib/load_status.ts +++ b/src/core/public/core_app/status/lib/load_status.ts @@ -134,7 +134,7 @@ export async function loadStatus({ try { response = await http.get('/api/status'); - } catch (e) { + } catch (e: any) { if ((e.response?.status ?? 0) >= 400) { notifications.toasts.addDanger( i18n.translate('core.statusPage.loadStatus.serverStatusCodeErrorMessage', { diff --git a/src/core/public/core_app/status/status_app.tsx b/src/core/public/core_app/status/status_app.tsx index a4663be7ec83..e38c78e768a0 100644 --- a/src/core/public/core_app/status/status_app.tsx +++ b/src/core/public/core_app/status/status_app.tsx @@ -72,7 +72,7 @@ export class StatusApp extends Component { try { const data = await loadStatus({ http, notifications }); this.setState({ loading: false, fetchError: false, data }); - } catch (e) { + } catch (e: any) { this.setState({ fetchError: true, loading: false, data: null }); } } diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts index 8fe5a36ebb55..a2dc876a7e4d 100644 --- a/src/core/public/core_system.ts +++ b/src/core/public/core_system.ts @@ -182,7 +182,7 @@ export class CoreSystem { await this.plugins.setup(core); return { fatalErrors: this.fatalErrorsSetup }; - } catch (error) { + } catch (error: any) { if (this.fatalErrorsSetup && (typeof error === 'string' || error instanceof Error)) { this.fatalErrorsSetup.add(error); } else { @@ -282,7 +282,7 @@ export class CoreSystem { return { application, }; - } catch (error) { + } catch (error: any) { if (this.fatalErrorsSetup && (typeof error === 'string' || error instanceof Error)) { this.fatalErrorsSetup.add(error); } else { diff --git a/src/core/public/http/fetch.ts b/src/core/public/http/fetch.ts index cefaa353f7fa..8d510fb907d1 100644 --- a/src/core/public/http/fetch.ts +++ b/src/core/public/http/fetch.ts @@ -116,7 +116,7 @@ export class Fetch { } else { resolve(interceptedResponse.body); } - } catch (error) { + } catch (error: any) { if (!(error instanceof HttpInterceptHaltError)) { reject(error); } @@ -168,7 +168,7 @@ export class Fetch { try { response = await window.fetch(request); - } catch (err) { + } catch (err: any) { throw new HttpFetchError(err.message, err.name ?? 'Error', request); } @@ -184,11 +184,11 @@ export class Fetch { try { body = JSON.parse(text); - } catch (err) { + } catch (err: any) { body = text; } } - } catch (err) { + } catch (err: any) { throw new HttpFetchError(err.message, err.name ?? 'Error', request, response, body); } diff --git a/src/core/public/http/intercept.ts b/src/core/public/http/intercept.ts index e3bc98dcba1d..25b7934fc911 100644 --- a/src/core/public/http/intercept.ts +++ b/src/core/public/http/intercept.ts @@ -137,7 +137,7 @@ export async function interceptResponse( } return { ...next, request, fetchOptions }; - } catch (err) { + } catch (err: any) { checkHalt(controller, err); throw err; } diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index 0bbf4549dd01..3267acd3e2fe 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -87,11 +87,13 @@ export interface InjectedMetadataParams { * @internal */ export class InjectedMetadataService { - private state = deepFreeze( - this.params.injectedMetadata - ) as InjectedMetadataParams['injectedMetadata']; + private state; - constructor(private readonly params: InjectedMetadataParams) {} + constructor(private readonly params: InjectedMetadataParams) { + this.state = deepFreeze( + this.params.injectedMetadata + ) as InjectedMetadataParams['injectedMetadata']; + } public start(): InjectedMetadataStart { return this.setup(); diff --git a/src/core/public/saved_objects/saved_objects_client.ts b/src/core/public/saved_objects/saved_objects_client.ts index d43b75b2171d..7befb69440ee 100644 --- a/src/core/public/saved_objects/saved_objects_client.ts +++ b/src/core/public/saved_objects/saved_objects_client.ts @@ -211,7 +211,7 @@ export class SavedObjectsClient { ); } }); - } catch (err) { + } catch (err: any) { queue.forEach((queueItem) => { queueItem.reject(err); }); diff --git a/src/core/public/ui_settings/ui_settings_api.test.ts b/src/core/public/ui_settings/ui_settings_api.test.ts index 490012c5f409..d82a2af7a192 100644 --- a/src/core/public/ui_settings/ui_settings_api.test.ts +++ b/src/core/public/ui_settings/ui_settings_api.test.ts @@ -55,7 +55,7 @@ async function settlePromise(promise: Promise) { isResolved: true, result: await promise, }; - } catch (error) { + } catch (error: any) { return { isRejected: true, error, diff --git a/src/core/public/ui_settings/ui_settings_api.ts b/src/core/public/ui_settings/ui_settings_api.ts index d8a68ac035a2..b873ba266d47 100644 --- a/src/core/public/ui_settings/ui_settings_api.ts +++ b/src/core/public/ui_settings/ui_settings_api.ts @@ -81,7 +81,7 @@ export class UiSettingsApi { if (error) { reject(error); } else { - resolve(resp); + resolve(resp!); } }, }; @@ -140,7 +140,7 @@ export class UiSettingsApi { changes: changes.values, }) ); - } catch (error) { + } catch (error: any) { changes.callback(error); } finally { this.sendInProgress = false; @@ -162,7 +162,7 @@ export class UiSettingsApi { accept: 'application/json', }, }); - } catch (err) { + } catch (err: any) { if (err.response) { if (err.response.status === 400) { throw new Error(err.body.message); diff --git a/src/core/public/ui_settings/ui_settings_client.ts b/src/core/public/ui_settings/ui_settings_client.ts index d2015468befa..3695135579b3 100644 --- a/src/core/public/ui_settings/ui_settings_client.ts +++ b/src/core/public/ui_settings/ui_settings_client.ts @@ -202,7 +202,7 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r this.cache = defaultsDeep({}, defaults, settings); this.saved$.next({ key, newValue: newVal, oldValue: initialVal }); return true; - } catch (error) { + } catch (error: any) { this.setLocally(key, initialVal); this.updateErrors$.next(error); return false; diff --git a/src/core/server/bootstrap.ts b/src/core/server/bootstrap.ts index 8defb17d2030..5c4c7cd8ee27 100644 --- a/src/core/server/bootstrap.ts +++ b/src/core/server/bootstrap.ts @@ -110,7 +110,7 @@ export async function bootstrap({ try { rawConfigService.reloadConfig(); - } catch (err) { + } catch (err: any) { return shutdown(err); } @@ -128,7 +128,7 @@ export async function bootstrap({ try { await root.setup(); await root.start(); - } catch (err) { + } catch (err: any) { await shutdown(err); } } diff --git a/src/core/server/environment/create_data_folder.test.ts b/src/core/server/environment/create_data_folder.test.ts index bc5df0daaffd..2a4f3ded0e1c 100644 --- a/src/core/server/environment/create_data_folder.test.ts +++ b/src/core/server/environment/create_data_folder.test.ts @@ -77,7 +77,7 @@ describe('createDataFolder', () => { mkdirMock.mockRejectedValue('some-error'); try { await createDataFolder({ pathConfig, logger }); - } catch (e) { + } catch (e: any) { /* trap */ } expect(logger.error).toHaveBeenCalledTimes(1); diff --git a/src/core/server/environment/create_data_folder.ts b/src/core/server/environment/create_data_folder.ts index 6683dd79a33d..2dd896a9775f 100644 --- a/src/core/server/environment/create_data_folder.ts +++ b/src/core/server/environment/create_data_folder.ts @@ -44,7 +44,7 @@ export async function createDataFolder({ // Create the data directory (recursively, if the a parent dir doesn't exist). // If it already exists, does nothing. await mkdir(dataFolder, { recursive: true }); - } catch (e) { + } catch (e: any) { logger.error(`Error trying to create data folder at ${dataFolder}: ${e}`); throw e; } diff --git a/src/core/server/environment/resolve_uuid.ts b/src/core/server/environment/resolve_uuid.ts index b7853f433852..11a756a35bf7 100644 --- a/src/core/server/environment/resolve_uuid.ts +++ b/src/core/server/environment/resolve_uuid.ts @@ -97,7 +97,7 @@ async function readUuidFromFile(filepath: string, logger: Logger): Promise> implements Sessi // is the safest option. this.log.warn(`Found ${session.length} auth sessions when we were only expecting 1.`); return null; - } catch (error) { + } catch (error: any) { this.log.debug(String(error)); return null; } @@ -129,7 +129,7 @@ function validateOptions(options: SessionStorageCookieOptions) { * @param server - hapi server to create SessionStorage for * @param cookieOptions - cookies configuration */ -export async function createCookieSessionStorageFactory( +export async function createCookieSessionStorageFactory>( log: Logger, server: Server, cookieOptions: SessionStorageCookieOptions, diff --git a/src/core/server/http/http_server.test.ts b/src/core/server/http/http_server.test.ts index 4db4c4fac17f..0695c047c89e 100644 --- a/src/core/server/http/http_server.test.ts +++ b/src/core/server/http/http_server.test.ts @@ -1043,7 +1043,7 @@ describe('body options', () => { expect(req.body).toBeInstanceOf(Buffer); expect(req.body.toString()).toBe(JSON.stringify({ test: 1 })); return res.ok({ body: req.route.options.body }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } @@ -1082,7 +1082,7 @@ describe('timeout options', () => { timeout: req.route.options.timeout, }, }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } @@ -1120,7 +1120,7 @@ describe('timeout options', () => { timeout: req.route.options.timeout, }, }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } @@ -1157,7 +1157,7 @@ describe('timeout options', () => { timeout: req.route.options.timeout, }, }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } @@ -1194,7 +1194,7 @@ describe('timeout options', () => { timeout: req.route.options.timeout, }, }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } @@ -1320,7 +1320,7 @@ test('should return a stream in the body', async () => { try { expect(req.body).toBeInstanceOf(Readable); return res.ok({ body: req.route.options.body }); - } catch (err) { + } catch (err: any) { return res.internalError({ body: err.message }); } } diff --git a/src/core/server/http/http_tools.test.ts b/src/core/server/http/http_tools.test.ts index 0759e4f2430d..a6b2a776b917 100644 --- a/src/core/server/http/http_tools.test.ts +++ b/src/core/server/http/http_tools.test.ts @@ -89,7 +89,7 @@ describe('defaultValidationErrorHandler', () => { try { defaultValidationErrorHandler({} as Request, {} as ResponseToolkit, error); - } catch (err) { + } catch (err: any) { // Verify the empty string gets corrected to 'value' expect(err.output.payload.validation.keys).toEqual(['0.type', 'value']); } diff --git a/src/core/server/http/https_redirect_server.ts b/src/core/server/http/https_redirect_server.ts index e0747466a389..9115c1dbb128 100644 --- a/src/core/server/http/https_redirect_server.ts +++ b/src/core/server/http/https_redirect_server.ts @@ -78,7 +78,7 @@ export class HttpsRedirectServer { try { await this.server.start(); this.log.debug(`http --> https redirect server running at ${this.server.info.uri}`); - } catch (err) { + } catch (err: any) { if (err.code === 'EADDRINUSE') { throw new Error( 'The redirect server failed to start up because port ' + diff --git a/src/core/server/http/lifecycle/auth.ts b/src/core/server/http/lifecycle/auth.ts index 8c8e91882940..b7386fa79ff1 100644 --- a/src/core/server/http/lifecycle/auth.ts +++ b/src/core/server/http/lifecycle/auth.ts @@ -226,7 +226,7 @@ export function adoptToHapiAuthFormat( throw new Error( `Unexpected result from Authenticate. Expected AuthResult or OpenSearchDashboardsResponse, but given: ${result}.` ); - } catch (error) { + } catch (error: any) { log.error(error); return hapiResponseAdapter.toInternalError(); } diff --git a/src/core/server/http/lifecycle/on_post_auth.ts b/src/core/server/http/lifecycle/on_post_auth.ts index 456e7ae24582..b97c3a69eba6 100644 --- a/src/core/server/http/lifecycle/on_post_auth.ts +++ b/src/core/server/http/lifecycle/on_post_auth.ts @@ -111,7 +111,7 @@ export function adoptToHapiOnPostAuthFormat(fn: OnPostAuthHandler, log: Logger) throw new Error( `Unexpected result from OnPostAuth. Expected OnPostAuthResult or OpenSearchDashboardsResponse, but given: ${result}.` ); - } catch (error) { + } catch (error: any) { log.error(error); return hapiResponseAdapter.toInternalError(); } diff --git a/src/core/server/http/lifecycle/on_pre_auth.ts b/src/core/server/http/lifecycle/on_pre_auth.ts index fe20d3281469..50e7b063e2ee 100644 --- a/src/core/server/http/lifecycle/on_pre_auth.ts +++ b/src/core/server/http/lifecycle/on_pre_auth.ts @@ -113,7 +113,7 @@ export function adoptToHapiOnPreAuth(fn: OnPreAuthHandler, log: Logger) { throw new Error( `Unexpected result from OnPreAuth. Expected OnPreAuthResult or OpenSearchDashboardsResponse, but given: ${result}.` ); - } catch (error) { + } catch (error: any) { log.error(error); return hapiResponseAdapter.toInternalError(); } diff --git a/src/core/server/http/lifecycle/on_pre_response.ts b/src/core/server/http/lifecycle/on_pre_response.ts index 19aceb81969d..6699b870364d 100644 --- a/src/core/server/http/lifecycle/on_pre_response.ts +++ b/src/core/server/http/lifecycle/on_pre_response.ts @@ -184,7 +184,7 @@ export function adoptToHapiOnPreResponseFormat(fn: OnPreResponseHandler, log: Lo ); } } - } catch (error) { + } catch (error: any) { log.error(error); const hapiResponseAdapter = new HapiResponseAdapter(responseToolkit); return hapiResponseAdapter.toInternalError(); diff --git a/src/core/server/http/lifecycle/on_pre_routing.ts b/src/core/server/http/lifecycle/on_pre_routing.ts index 968894020c52..fd1cc5c61b94 100644 --- a/src/core/server/http/lifecycle/on_pre_routing.ts +++ b/src/core/server/http/lifecycle/on_pre_routing.ts @@ -135,7 +135,7 @@ export function adoptToHapiOnRequest(fn: OnPreRoutingHandler, log: Logger) { throw new Error( `Unexpected result from OnPreRouting. Expected OnPreRoutingResult or OpenSearchDashboardsResponse, but given: ${result}.` ); - } catch (error) { + } catch (error: any) { log.error(error); return hapiResponseAdapter.toInternalError(); } diff --git a/src/core/server/http/router/error_wrapper.ts b/src/core/server/http/router/error_wrapper.ts index f81532562a9a..fc1118df72e6 100644 --- a/src/core/server/http/router/error_wrapper.ts +++ b/src/core/server/http/router/error_wrapper.ts @@ -35,7 +35,7 @@ export const wrapErrors: RequestHandlerWrapper = (handler) => { return async (context, request, response) => { try { return await handler(context, request, response); - } catch (e) { + } catch (e: any) { if (Boom.isBoom(e)) { return response.customError({ body: e.output.payload, diff --git a/src/core/server/http/router/router.ts b/src/core/server/http/router/router.ts index c99134e5ce8f..879f4f016701 100644 --- a/src/core/server/http/router/router.ts +++ b/src/core/server/http/router/router.ts @@ -278,7 +278,7 @@ export class Router implements IRouter { const hapiResponseAdapter = new HapiResponseAdapter(responseToolkit); try { opensearchDashboardsRequest = OpenSearchDashboardsRequest.from(request, routeSchemas); - } catch (e) { + } catch (e: any) { return hapiResponseAdapter.toBadRequest(e.message); } @@ -288,7 +288,7 @@ export class Router implements IRouter { opensearchDashboardsResponseFactory ); return hapiResponseAdapter.handle(opensearchDashboardsResponse); - } catch (e) { + } catch (e: any) { this.log.error(e); // forward 401 errors from OpenSearch client if (isOpenSearchUnauthorizedError(e)) { diff --git a/src/core/server/http/router/validator/validator.ts b/src/core/server/http/router/validator/validator.ts index d82bef3b6e1e..9dcd9d9ec178 100644 --- a/src/core/server/http/router/validator/validator.ts +++ b/src/core/server/http/router/validator/validator.ts @@ -267,7 +267,7 @@ export class RouteValidator

{ let result: ReturnType; try { result = validateFn(data, RouteValidator.ResultFactory); - } catch (err) { + } catch (err: any) { result = { error: new RouteValidationError(err) }; } diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index ae7e85b98d67..a0b54e19a88d 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -335,7 +335,7 @@ export class LegacyService implements CoreService { if (autoListen) { try { await osdServer.listen(); - } catch (err) { + } catch (err: any) { await osdServer.close(); throw err; } diff --git a/src/core/server/logging/appenders/file/file_appender.ts b/src/core/server/logging/appenders/file/file_appender.ts index 87959641e9fb..9d00d26fe654 100644 --- a/src/core/server/logging/appenders/file/file_appender.ts +++ b/src/core/server/logging/appenders/file/file_appender.ts @@ -82,7 +82,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/core/server/metrics/collectors/cgroup.ts b/src/core/server/metrics/collectors/cgroup.ts index 6f38ea3672cc..c0cd07469c40 100644 --- a/src/core/server/metrics/collectors/cgroup.ts +++ b/src/core/server/metrics/collectors/cgroup.ts @@ -80,7 +80,7 @@ export class OsCgroupMetricsCollector implements MetricsCollector { distro: distro.dist, distroRelease: `${distro.dist}-${distro.release}`, }; - } catch (e) { + } catch (e: any) { // ignore errors } } diff --git a/src/core/server/opensearch/client/cluster_client.test.ts b/src/core/server/opensearch/client/cluster_client.test.ts index 1510d2b148fe..203cbd7f8647 100644 --- a/src/core/server/opensearch/client/cluster_client.test.ts +++ b/src/core/server/opensearch/client/cluster_client.test.ts @@ -434,7 +434,7 @@ describe('ClusterClient', () => { let closeScopedClient: () => void; internalClient.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeInternalClient = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); @@ -442,7 +442,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/opensearch/legacy/cluster_client.ts b/src/core/server/opensearch/legacy/cluster_client.ts index bb8884fd3952..66ab1ed45206 100644 --- a/src/core/server/opensearch/legacy/cluster_client.ts +++ b/src/core/server/opensearch/legacy/cluster_client.ts @@ -89,7 +89,7 @@ const callAPI = async ( } return request.then(resolve, reject); }); - } catch (err) { + } catch (err: any) { if (!options.wrap401Errors || err.statusCode !== 401) { throw err; } diff --git a/src/core/server/opensearch/legacy/errors.ts b/src/core/server/opensearch/legacy/errors.ts index 3894c7984379..c7723192ddf0 100644 --- a/src/core/server/opensearch/legacy/errors.ts +++ b/src/core/server/opensearch/legacy/errors.ts @@ -82,7 +82,7 @@ function decorate( * ```js * try { * await client.asScoped(request).callAsCurrentUser(...); - * } catch (err) { + * } catch (err: any) { * if (OpenSearchErrorHelpers.isNotAuthorizedError(err)) { * const authHeader = err.output.headers['WWW-Authenticate']; * } diff --git a/src/core/server/opensearch/version_check/ensure_opensearch_version.ts b/src/core/server/opensearch/version_check/ensure_opensearch_version.ts index fc35818e2929..df4b19603f0a 100644 --- a/src/core/server/opensearch/version_check/ensure_opensearch_version.ts +++ b/src/core/server/opensearch/version_check/ensure_opensearch_version.ts @@ -108,7 +108,7 @@ export const getNodeId = async ( // When all nodes share the same cluster_id, return _local return '_local'; - } catch (e) { + } catch (e: any) { return null; } }; diff --git a/src/core/server/plugins/discovery/plugin_manifest_parser.ts b/src/core/server/plugins/discovery/plugin_manifest_parser.ts index 0f39f14b0ce5..c81af159523f 100644 --- a/src/core/server/plugins/discovery/plugin_manifest_parser.ts +++ b/src/core/server/plugins/discovery/plugin_manifest_parser.ts @@ -93,14 +93,14 @@ export async function parseManifest( let manifestContent; try { manifestContent = await fsReadFileAsync(manifestPath); - } catch (err) { + } catch (err: any) { throw PluginDiscoveryError.missingManifest(manifestPath, err); } let manifest: Partial; try { manifest = JSON.parse(manifestContent.toString()); - } catch (err) { + } catch (err: any) { throw PluginDiscoveryError.invalidManifest(manifestPath, err); } @@ -220,7 +220,7 @@ export async function parseManifest( export async function isNewPlatformPlugin(pluginPath: string) { try { return (await fsStatAsync(resolve(pluginPath, MANIFEST_FILE_NAME))).isFile(); - } catch (err) { + } catch (err: any) { return false; } } diff --git a/src/core/server/rendering/rendering_service.tsx b/src/core/server/rendering/rendering_service.tsx index 2362be550078..eb13b34dc922 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/src/core/server/rendering/rendering_service.tsx @@ -181,7 +181,7 @@ export class RenderingService { passphrase: sslConfig.keyPassphrase, rejectUnauthorized: false, }); - } catch (e) { + } catch (e: any) { this.logger.get('branding').error('HTTP agent failed to setup for SSL.'); } } diff --git a/src/core/server/root/index.ts b/src/core/server/root/index.ts index 73b37eadc4db..647fde6f5e87 100644 --- a/src/core/server/root/index.ts +++ b/src/core/server/root/index.ts @@ -62,7 +62,7 @@ export class Root { await this.setupLogging(); this.log.debug('setting up root'); return await this.server.setup(); - } catch (e) { + } catch (e: any) { await this.shutdown(e); throw e; } @@ -72,7 +72,7 @@ export class Root { this.log.debug('starting root'); try { return await this.server.start(); - } catch (e) { + } catch (e: any) { await this.shutdown(e); throw e; } diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts index 2cf718148375..d7722f161b70 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts @@ -578,7 +578,7 @@ describe('DocumentMigrator', () => { try { migrator.migrate(_.cloneDeep(failedDoc)); expect('Did not throw').toEqual('But it should have!'); - } catch (error) { + } catch (error: any) { expect(error.message).toMatch(/Dang diggity!/); const warning = loggingSystemMock.collect(mockLoggerFactory).warn[0][0]; expect(warning).toContain(JSON.stringify(failedDoc)); diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.ts b/src/core/server/saved_objects/migrations/core/document_migrator.ts index e6a5f4fb3697..d30632b691b9 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.ts @@ -319,7 +319,7 @@ function wrapWithTry( } return result; - } catch (error) { + } catch (error: any) { const failedTransform = `${type}:${version}`; const failedDoc = JSON.stringify(doc); log.warn( diff --git a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts index 17948eb0f2e9..b9b031a04a85 100644 --- a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts +++ b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts @@ -94,7 +94,7 @@ function transformNonBlocking( setImmediate(() => { try { resolve(transform(doc)); - } catch (e) { + } catch (e: any) { reject(e); } }); diff --git a/src/core/server/saved_objects/migrations/core/migration_coordinator.ts b/src/core/server/saved_objects/migrations/core/migration_coordinator.ts index f5b6053322b1..902990a19752 100644 --- a/src/core/server/saved_objects/migrations/core/migration_coordinator.ts +++ b/src/core/server/saved_objects/migrations/core/migration_coordinator.ts @@ -85,7 +85,7 @@ interface Opts { export async function coordinateMigration(opts: Opts): Promise { try { return await opts.runMigration(); - } catch (error) { + } catch (error: any) { if (handleIndexExists(error, opts.log)) { await waitForMigration(opts.isMigrated, opts.pollInterval); return { status: 'skipped' }; diff --git a/src/core/server/saved_objects/migrations/core/migration_opensearch_client.test.ts b/src/core/server/saved_objects/migrations/core/migration_opensearch_client.test.ts index 91f11cbd4878..5f2a664c8728 100644 --- a/src/core/server/saved_objects/migrations/core/migration_opensearch_client.test.ts +++ b/src/core/server/saved_objects/migrations/core/migration_opensearch_client.test.ts @@ -72,7 +72,7 @@ describe('MigrationOpenSearchClient', () => { client.bulk = jest.fn().mockRejectedValue(new Error('reason')); try { await migrationOpenSearchClient.bulk({ body: [] }); - } catch (e) { + } catch (e: any) { expect(SavedObjectsErrorHelpers.isSavedObjectsClientError(e)).toBe(false); } }); diff --git a/src/core/server/saved_objects/migrations/core/opensearch_index.ts b/src/core/server/saved_objects/migrations/core/opensearch_index.ts index 7df5c3881cdf..084d89011e79 100644 --- a/src/core/server/saved_objects/migrations/core/opensearch_index.ts +++ b/src/core/server/saved_objects/migrations/core/opensearch_index.ts @@ -213,7 +213,7 @@ export async function migrationsUpToDate( assertResponseIncludeAllShards(body); return body.count === 0; - } catch (e) { + } catch (e: any) { // retry for Service Unavailable if (e.status !== 503 || retryCount === 0) { throw e; diff --git a/src/core/server/saved_objects/routes/import.ts b/src/core/server/saved_objects/routes/import.ts index b157feb0860e..201d13cfd83b 100644 --- a/src/core/server/saved_objects/routes/import.ts +++ b/src/core/server/saved_objects/routes/import.ts @@ -85,7 +85,7 @@ export const registerImportRoute = (router: IRouter, config: SavedObjectConfig) let readStream: Readable; try { readStream = await createSavedObjectsStreamFromNdJson(file); - } catch (e) { + } catch (e: any) { return res.badRequest({ body: e, }); diff --git a/src/core/server/saved_objects/routes/resolve_import_errors.ts b/src/core/server/saved_objects/routes/resolve_import_errors.ts index 5e07125671f1..e955186d9160 100644 --- a/src/core/server/saved_objects/routes/resolve_import_errors.ts +++ b/src/core/server/saved_objects/routes/resolve_import_errors.ts @@ -92,7 +92,7 @@ export const registerResolveImportErrorsRoute = (router: IRouter, config: SavedO let readStream: Readable; try { readStream = await createSavedObjectsStreamFromNdJson(file); - } catch (e) { + } catch (e: any) { return res.badRequest({ body: e, }); diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index bccfd8ff2265..f9fd8f7035f1 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -780,7 +780,7 @@ export class SavedObjectsRepository { if (filter) { kueryNode = validateConvertFilterToKueryNode(allowedTypes, filter, this._mappings); } - } catch (e) { + } catch (e: any) { if (e.name === 'DQLSyntaxError') { throw SavedObjectsErrorHelpers.createBadRequestError('DQLSyntaxError: ' + e.message); } else { diff --git a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts index 6dc61ae5b794..d558bc5c8192 100644 --- a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts +++ b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts @@ -95,7 +95,7 @@ describe('SavedObjectsRepository#createRepository', () => { callAdminCluster, ['unMappedType1', 'unmappedType2'] ); - } catch (e) { + } catch (e: any) { expect(e).toMatchInlineSnapshot( `[Error: Missing mappings for saved objects types: 'unMappedType1, unmappedType2']` ); diff --git a/src/core/server/saved_objects/service/lib/repository_opensearch_client.test.ts b/src/core/server/saved_objects/service/lib/repository_opensearch_client.test.ts index a09075e3da7e..28e2abdf5084 100644 --- a/src/core/server/saved_objects/service/lib/repository_opensearch_client.test.ts +++ b/src/core/server/saved_objects/service/lib/repository_opensearch_client.test.ts @@ -72,7 +72,7 @@ describe('RepositoryOpenSearchClient', () => { client.bulk = jest.fn().mockRejectedValue(new Error('reason')); try { await repositoryClient.bulk({ body: [] }); - } catch (e) { + } catch (e: any) { expect(SavedObjectsErrorHelpers.isSavedObjectsClientError(e)).toBe(true); } }); diff --git a/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts b/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts index 5c55532afc1a..9d3d55d8bef1 100644 --- a/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts +++ b/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts @@ -60,7 +60,7 @@ export function createRepositoryOpenSearchClient( return await retryCallCluster(() => (client[key] as Function)(params, { maxRetries: 0, ...options }) ); - } catch (e) { + } catch (e: any) { throw decorateOpenSearchError(e); } }, diff --git a/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts2 b/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts2 index d9ae6fd26e1a..21651c5429d2 100644 --- a/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts2 +++ b/src/core/server/saved_objects/service/lib/repository_opensearch_client.ts2 @@ -58,7 +58,7 @@ export function createRepositoryOpenSearchClient(client: OpenSearchClient): Repo return await retryCallCluster(() => (client[key] as Function)(params, { maxRetries: 0, ...options }) ); - } catch (e) { + } catch (e: any) { throw decorateOpenSearchError(e); } }, diff --git a/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts index 5bbb0a1fe24f..ba53896332e5 100644 --- a/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts +++ b/src/core/server/saved_objects/service/lib/search_dsl/query_params.ts @@ -319,7 +319,7 @@ const getMatchPhrasePrefixFields = ({ if (rawBoost) { try { boost = parseInt(rawBoost, 10); - } catch (e) { + } catch (e: any) { boost = 1; } } diff --git a/src/core/server/saved_objects/version/decode_version.test.ts b/src/core/server/saved_objects/version/decode_version.test.ts index d7f0df831aef..fc843a18ef07 100644 --- a/src/core/server/saved_objects/version/decode_version.test.ts +++ b/src/core/server/saved_objects/version/decode_version.test.ts @@ -46,7 +46,7 @@ Object { let error; try { decodeVersion('[1,4]'); - } catch (err) { + } catch (err: any) { error = err; } @@ -69,7 +69,7 @@ Object { let error; try { decodeVersion('MSwy'); - } catch (err) { + } catch (err: any) { error = err; } @@ -92,7 +92,7 @@ Object { let error; try { decodeVersion('WzEsMy41XQ=='); - } catch (err) { + } catch (err: any) { error = err; } diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts index eb23e78b1756..df7977cb5846 100644 --- a/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts +++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.test.ts @@ -176,7 +176,7 @@ describe('uiSettings/createOrUpgradeSavedConfig', function () { try { await run(); throw new Error('Expected run() to throw an error'); - } catch (error) { + } catch (error: any) { expect(error.message).toBe('foo'); } diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts index 639dd09249ff..04675b569bbd 100644 --- a/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts +++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/create_or_upgrade_saved_config.ts @@ -64,7 +64,7 @@ export async function createOrUpgradeSavedConfig( try { // create the new SavedConfig await savedObjectsClient.create('config', attributes, { id: version }); - } catch (error) { + } catch (error: any) { if (handleWriteErrors) { if (SavedObjectsErrorHelpers.isConflictError(error)) { return; diff --git a/src/core/server/ui_settings/routes/delete.ts b/src/core/server/ui_settings/routes/delete.ts index d42eb948259e..aa4a983fc668 100644 --- a/src/core/server/ui_settings/routes/delete.ts +++ b/src/core/server/ui_settings/routes/delete.ts @@ -54,7 +54,7 @@ export function registerDeleteRoute(router: IRouter) { settings: await uiSettingsClient.getUserProvided(), }, }); - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isSavedObjectsClientError(error)) { return response.customError({ body: error, diff --git a/src/core/server/ui_settings/routes/get.ts b/src/core/server/ui_settings/routes/get.ts index 000d16a37358..3d4baa808524 100644 --- a/src/core/server/ui_settings/routes/get.ts +++ b/src/core/server/ui_settings/routes/get.ts @@ -42,7 +42,7 @@ export function registerGetRoute(router: IRouter) { settings: await uiSettingsClient.getUserProvided(), }, }); - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isSavedObjectsClientError(error)) { return response.customError({ body: error, diff --git a/src/core/server/ui_settings/routes/set.ts b/src/core/server/ui_settings/routes/set.ts index d30b7d705d6a..99ce6082eade 100644 --- a/src/core/server/ui_settings/routes/set.ts +++ b/src/core/server/ui_settings/routes/set.ts @@ -60,7 +60,7 @@ export function registerSetRoute(router: IRouter) { settings: await uiSettingsClient.getUserProvided(), }, }); - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isSavedObjectsClientError(error)) { return response.customError({ body: error, diff --git a/src/core/server/ui_settings/routes/set_many.ts b/src/core/server/ui_settings/routes/set_many.ts index 8698445a2c5b..c014196d8711 100644 --- a/src/core/server/ui_settings/routes/set_many.ts +++ b/src/core/server/ui_settings/routes/set_many.ts @@ -56,7 +56,7 @@ export function registerSetManyRoute(router: IRouter) { settings: await uiSettingsClient.getUserProvided(), }, }); - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isSavedObjectsClientError(error)) { return response.customError({ body: error, diff --git a/src/core/server/ui_settings/ui_settings_client.test.ts b/src/core/server/ui_settings/ui_settings_client.test.ts index 72461653d652..e9ba5d51af61 100644 --- a/src/core/server/ui_settings/ui_settings_client.test.ts +++ b/src/core/server/ui_settings/ui_settings_client.test.ts @@ -129,7 +129,7 @@ describe('ui settings', () => { try { await uiSettings.setMany({ foo: 'bar' }); throw new Error('expected setMany to throw a NotFound error'); - } catch (error) { + } catch (error: any) { expect(SavedObjectsClient.errors.isNotFoundError(error)).toBe(true); } @@ -152,7 +152,7 @@ describe('ui settings', () => { bar: 'box', foo: 'baz', }); - } catch (error) { + } catch (error: any) { expect(error).toBeInstanceOf(CannotOverrideError); expect(error.message).toBe('Unable to update "foo" because it is overridden'); } @@ -211,7 +211,7 @@ describe('ui settings', () => { try { await uiSettings.set('foo', 'baz'); - } catch (error) { + } catch (error: any) { expect(error).toBeInstanceOf(CannotOverrideError); expect(error.message).toBe('Unable to update "foo" because it is overridden'); } @@ -255,7 +255,7 @@ describe('ui settings', () => { try { await uiSettings.remove('foo'); - } catch (error) { + } catch (error: any) { expect(error).toBeInstanceOf(CannotOverrideError); expect(error.message).toBe('Unable to update "foo" because it is overridden'); } @@ -311,7 +311,7 @@ describe('ui settings', () => { try { await uiSettings.setMany({ baz: 'baz', foo: 'foo' }); - } catch (error) { + } catch (error: any) { expect(error).toBeInstanceOf(CannotOverrideError); expect(error.message).toBe('Unable to update "foo" because it is overridden'); } @@ -451,7 +451,7 @@ describe('ui settings', () => { try { await uiSettings.getUserProvided(); throw new Error('expect getUserProvided() to throw'); - } catch (err) { + } catch (err: any) { expect(err).toBe(error); } }); @@ -465,7 +465,7 @@ describe('ui settings', () => { try { await uiSettings.getUserProvided(); throw new Error('expect getUserProvided() to throw'); - } catch (err) { + } catch (err: any) { expect(err).toBe(error); } }); diff --git a/src/core/server/ui_settings/ui_settings_client.ts b/src/core/server/ui_settings/ui_settings_client.ts index e7e5030035b8..5a4e4cf6dfe9 100644 --- a/src/core/server/ui_settings/ui_settings_client.ts +++ b/src/core/server/ui_settings/ui_settings_client.ts @@ -184,7 +184,7 @@ export class UiSettingsClient implements IUiSettingsClient { filteredValues[key] = { userValue: userValue as T, }; - } catch (error) { + } catch (error: any) { this.log.warn(`Ignore invalid UiSettings value. ${error}.`); } } @@ -202,7 +202,7 @@ export class UiSettingsClient implements IUiSettingsClient { changes = this.translateChanges(changes, 'timeline', 'timelion'); try { await this.savedObjectsClient.update(this.type, this.id, changes); - } catch (error) { + } catch (error: any) { if (!SavedObjectsErrorHelpers.isNotFoundError(error) || !autoCreateOrUpgradeIfMissing) { throw error; } @@ -229,7 +229,7 @@ export class UiSettingsClient implements IUiSettingsClient { try { const resp = await this.savedObjectsClient.get>(this.type, this.id); return this.translateChanges(resp.attributes, 'timelion', 'timeline'); - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isNotFoundError(error) && autoCreateOrUpgradeIfMissing) { const failedUpgradeAttributes = await createOrUpgradeSavedConfig({ savedObjectsClient: this.savedObjectsClient, diff --git a/src/core/server/utils/streams/concat_stream.test.ts b/src/core/server/utils/streams/concat_stream.test.ts index 350fc84f0376..4dba97889d64 100644 --- a/src/core/server/utils/streams/concat_stream.test.ts +++ b/src/core/server/utils/streams/concat_stream.test.ts @@ -69,14 +69,14 @@ describe('concatStream', () => { let promise; try { promise = createPromiseFromStreams([createListStream([1, '1']), createConcatStream()]); - } catch (err) { + } catch (err: any) { throw new Error('createPromiseFromStreams() should not fail synchronously'); } try { await promise; throw new Error('Promise should have rejected'); - } catch (err) { + } catch (err: any) { expect(err).toBeInstanceOf(Error); expect(err.message).toContain('concat'); } diff --git a/src/core/server/utils/streams/intersperse_stream.ts b/src/core/server/utils/streams/intersperse_stream.ts index 7207d66dfd22..4123e30c863f 100644 --- a/src/core/server/utils/streams/intersperse_stream.ts +++ b/src/core/server/utils/streams/intersperse_stream.ts @@ -67,7 +67,7 @@ export function createIntersperseStream(intersperseChunk: string | Buffer) { this.push(chunk); callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/src/core/server/utils/streams/map_stream.ts b/src/core/server/utils/streams/map_stream.ts index 228bac1989df..e23c39fb687a 100644 --- a/src/core/server/utils/streams/map_stream.ts +++ b/src/core/server/utils/streams/map_stream.ts @@ -39,7 +39,7 @@ export function createMapStream(fn: (value: T, i: number) => void) { try { this.push(await fn(value, i++)); done(); - } catch (err) { + } catch (err: any) { done(err); } }, diff --git a/src/core/server/utils/streams/promise_from_streams.test.ts b/src/core/server/utils/streams/promise_from_streams.test.ts index 907aab52b761..13f2bcd05c72 100644 --- a/src/core/server/utils/streams/promise_from_streams.test.ts +++ b/src/core/server/utils/streams/promise_from_streams.test.ts @@ -137,7 +137,7 @@ describe('promiseFromStreams', () => { try { await createPromiseFromStreams([readStream, transformStream]); throw new Error('Should fail'); - } catch (e) { + } catch (e: any) { expect(e.message).toBe('Test error'); expect(destroyCalled).toBe(true); } diff --git a/src/core/server/utils/streams/reduce_stream.ts b/src/core/server/utils/streams/reduce_stream.ts index 232c0d5585b7..a862f58db6a1 100644 --- a/src/core/server/utils/streams/reduce_stream.ts +++ b/src/core/server/utils/streams/reduce_stream.ts @@ -77,7 +77,7 @@ export function createReduceStream( } callback(); - } catch (err) { + } catch (err: any) { failed = true; callback(err); } diff --git a/src/core/server/utils/streams/replace_stream.ts b/src/core/server/utils/streams/replace_stream.ts index 9da36eb59932..cc5f618fc860 100644 --- a/src/core/server/utils/streams/replace_stream.ts +++ b/src/core/server/utils/streams/replace_stream.ts @@ -79,7 +79,7 @@ export function createReplaceStream(toReplace: string, replacement: string | Buf } done(); - } catch (err) { + } catch (err: any) { done(err); } }, diff --git a/src/core/server/utils/streams/split_stream.ts b/src/core/server/utils/streams/split_stream.ts index be65ced66c09..bf2477809c41 100644 --- a/src/core/server/utils/streams/split_stream.ts +++ b/src/core/server/utils/streams/split_stream.ts @@ -67,7 +67,7 @@ export function createSplitStream(splitChunk: string | Uint8Array) { unsplitBuffer = toSplit; callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, @@ -77,7 +77,7 @@ export function createSplitStream(splitChunk: string | Uint8Array) { this.push(unsplitBuffer.toString('utf8')); callback(); - } catch (err) { + } catch (err: any) { callback(err); } }, diff --git a/src/core/utils/context.ts b/src/core/utils/context.ts index 6109cb70eafc..fc89a6d9f417 100644 --- a/src/core/utils/context.ts +++ b/src/core/utils/context.ts @@ -234,7 +234,7 @@ export class ContextContainer> provider: IContextProvider ): this => { if (this.contextProviders.has(contextName)) { - throw new Error(`Context provider for ${contextName} has already been registered.`); + throw new Error(`Context provider for ${String(contextName)} has already been registered.`); } if (source !== this.coreId && !this.pluginDependencies.has(source)) { throw new Error(`Cannot register context for unknown plugin: ${source.toString()}`); diff --git a/src/dev/build/lib/build.test.ts b/src/dev/build/lib/build.test.ts index 140237437ad1..a08364a3b066 100644 --- a/src/dev/build/lib/build.test.ts +++ b/src/dev/build/lib/build.test.ts @@ -42,6 +42,7 @@ const config = new Config( darwin: false, linux: false, linuxArm: false, + windows: false, }, { version: '1.0.0', diff --git a/src/dev/build/lib/download.ts b/src/dev/build/lib/download.ts index cf5c0f675f82..d856bf0ccab7 100644 --- a/src/dev/build/lib/download.ts +++ b/src/dev/build/lib/download.ts @@ -45,7 +45,7 @@ import { mkdirp } from './fs'; function tryUnlink(path: string) { try { unlinkSync(path); - } catch (error) { + } catch (error: any) { if (error.code !== 'ENOENT') { throw error; } @@ -70,7 +70,7 @@ export async function download(options: DownloadOptions): Promise { await mkdirp(dirname(destination)); const fileHandle = openSync(destination, 'w'); - let error; + let error: Error | undefined; try { log.debug(`Attempting download of ${url}`, chalk.dim(sha256)); @@ -101,7 +101,7 @@ export async function download(options: DownloadOptions): Promise { `Downloaded checksum ${downloadedSha256} does not match the expected sha256 checksum.` ); } - } catch (_error) { + } catch (_error: any) { error = _error; } finally { closeSync(fileHandle); @@ -112,7 +112,7 @@ export async function download(options: DownloadOptions): Promise { return; } - log.debug(`Download failed: ${error.message}`); + log.debug(`Download failed: ${error.message!}`); // cleanup downloaded data and log error log.debug(`Deleting downloaded data at ${destination}`); diff --git a/src/dev/build/lib/fs.ts b/src/dev/build/lib/fs.ts index 53fc241f7722..601d70c22c18 100644 --- a/src/dev/build/lib/fs.ts +++ b/src/dev/build/lib/fs.ts @@ -67,7 +67,7 @@ export function isFileAccessible(path: string) { try { fs.accessSync(path); return true; - } catch (e) { + } catch (e: any) { return false; } } @@ -145,7 +145,7 @@ export async function deleteEmptyFolders( dryRun: true, }); - const foldersToDelete = emptyFoldersList.filter((folderToDelete) => { + const foldersToDelete = emptyFoldersList.filter((folderToDelete: string) => { return !foldersToKeep.some((folderToKeep) => folderToDelete.includes(folderToKeep)); }); const deletedEmptyFolders = await del(foldersToDelete, { diff --git a/src/dev/build/lib/integration_tests/download.test.ts b/src/dev/build/lib/integration_tests/download.test.ts index 51b300513c99..54e91eceb579 100644 --- a/src/dev/build/lib/integration_tests/download.test.ts +++ b/src/dev/build/lib/integration_tests/download.test.ts @@ -129,7 +129,7 @@ it('rejects and deletes destination if sha256 does not match', async () => { sha256: 'bar', }); throw new Error('Expected download() to reject'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty( 'message', expect.stringContaining('does not match the expected sha256 checksum') @@ -139,7 +139,7 @@ it('rejects and deletes destination if sha256 does not match', async () => { try { readFileSync(TMP_DESTINATION); throw new Error('Expected download to be deleted'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('code', 'ENOENT'); } }); @@ -209,7 +209,7 @@ describe('reties download retries: number of times', () => { retries: 5, }); throw new Error('Expected download() to reject'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty( 'message', expect.stringContaining('Request failed with status code 500') @@ -230,7 +230,7 @@ describe('sha256 option not supplied', () => { }); throw new Error('expected download() to reject'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('message', expect.stringContaining('refusing to download')); } }); diff --git a/src/dev/build/lib/integration_tests/fs.test.ts b/src/dev/build/lib/integration_tests/fs.test.ts index 1ad9afa54ef8..319024164b47 100644 --- a/src/dev/build/lib/integration_tests/fs.test.ts +++ b/src/dev/build/lib/integration_tests/fs.test.ts @@ -76,7 +76,7 @@ describe('mkdirp()', () => { try { await mkdirp('foo/bar'); throw new Error('Expected mkdirp() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -96,7 +96,7 @@ describe('write()', () => { // @ts-expect-error missing content intentional await write('foo/bar'); throw new Error('Expected write() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -121,7 +121,7 @@ describe('read()', () => { try { await read('foo/bar'); throw new Error('Expected read() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -136,7 +136,7 @@ describe('getChildPaths()', () => { try { await getChildPaths('foo/bar'); throw new Error('Expected getChildPaths() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -154,7 +154,7 @@ describe('getChildPaths()', () => { try { await getChildPaths(resolve(FIXTURES, 'notrealpath')); throw new Error('Expected getChildPaths() to reject'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('code', 'ENOENT'); } }); @@ -165,7 +165,7 @@ describe('copyAll()', () => { try { await copyAll('foo/bar', __dirname); throw new Error('Expected copyAll() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -174,7 +174,7 @@ describe('copyAll()', () => { try { await copyAll(__dirname, 'foo/bar'); throw new Error('Expected copyAll() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -183,7 +183,7 @@ describe('copyAll()', () => { try { await copyAll('foo/bar', 'foo/bar'); throw new Error('Expected copyAll() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -220,14 +220,14 @@ describe('copyAll()', () => { try { statSync(resolve(destination, 'bin/world_executable')); throw new Error('expected bin/world_executable to not by copied'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('code', 'ENOENT'); } try { statSync(resolve(destination, 'foo_dir/.bar')); throw new Error('expected foo_dir/.bar to not by copied'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('code', 'ENOENT'); } @@ -244,7 +244,7 @@ describe('copyAll()', () => { try { statSync(resolve(destination, 'bin/world_executable')); throw new Error('expected bin/world_executable to not by copied'); - } catch (error) { + } catch (error: any) { expect(error).toHaveProperty('code', 'ENOENT'); } @@ -274,7 +274,7 @@ describe('getFileHash()', () => { try { await getFileHash('foo/bar', 'some content'); throw new Error('Expected getFileHash() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -299,7 +299,7 @@ describe('untar()', () => { try { await untar('foo/bar', '**/*'); throw new Error('Expected untar() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -308,7 +308,7 @@ describe('untar()', () => { try { await untar(__dirname, '**/*'); throw new Error('Expected untar() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -317,7 +317,7 @@ describe('untar()', () => { try { await untar('foo/bar', '**/*'); throw new Error('Expected untar() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -347,7 +347,7 @@ describe('gunzip()', () => { try { await gunzip('foo/bar', '**/*'); throw new Error('Expected gunzip() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -356,7 +356,7 @@ describe('gunzip()', () => { try { await gunzip(__dirname, '**/*'); throw new Error('Expected gunzip() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); @@ -365,7 +365,7 @@ describe('gunzip()', () => { try { await gunzip('foo/bar', '**/*'); throw new Error('Expected gunzip() to reject'); - } catch (error) { + } catch (error: any) { assertNonAbsoluteError(error); } }); diff --git a/src/dev/build/lib/runner.test.ts b/src/dev/build/lib/runner.test.ts index 6678a15fff5a..abe2166b3490 100644 --- a/src/dev/build/lib/runner.test.ts +++ b/src/dev/build/lib/runner.test.ts @@ -76,6 +76,7 @@ const setup = async () => { linux: false, linuxArm: false, darwin: false, + windows: false, }, }); diff --git a/src/dev/build/lib/runner.ts b/src/dev/build/lib/runner.ts index 5a404423d23d..81d1f72de22b 100644 --- a/src/dev/build/lib/runner.ts +++ b/src/dev/build/lib/runner.ts @@ -68,7 +68,7 @@ export function createRunner({ config, log }: Options) { try { await task.run(config, log, lastArg); log.success(chalk.green('✓'), time()); - } catch (error) { + } catch (error: any) { if (!isErrorLogged(error)) { log.error(`failure ${time()}`); log.error(error); diff --git a/src/dev/build/lib/watch_stdio_for_line.ts b/src/dev/build/lib/watch_stdio_for_line.ts index 1e372a6c8a9e..430904a05e2c 100644 --- a/src/dev/build/lib/watch_stdio_for_line.ts +++ b/src/dev/build/lib/watch_stdio_for_line.ts @@ -80,13 +80,13 @@ export async function watchStdioForLine( } }), createPromiseFromStreams([ - proc.stdout, + proc.stdout!, createSplitStream('\n'), skipLastEmptyLineStream(), createMapStream(onLogLine), ]), createPromiseFromStreams([ - proc.stderr, + proc.stderr!, createSplitStream('\n'), skipLastEmptyLineStream(), createMapStream(onLogLine), diff --git a/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts index 3aff61e7cf4f..d727b1e87b69 100644 --- a/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/download_node_builds_task.test.ts @@ -65,6 +65,7 @@ async function setup({ failOnUrl }: { failOnUrl?: string } = {}) { linux: false, linuxArm: false, darwin: false, + windows: false, }, }); diff --git a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts index ccb75897ccfd..a8aff206449f 100644 --- a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts @@ -74,6 +74,7 @@ async function setup(actualShaSums?: Record) { linux: false, linuxArm: false, darwin: false, + windows: false, }, }); diff --git a/src/dev/build/tasks/os_packages/create_os_package_tasks.test.ts b/src/dev/build/tasks/os_packages/create_os_package_tasks.test.ts index 2093c7875191..9db6d51dbdbb 100644 --- a/src/dev/build/tasks/os_packages/create_os_package_tasks.test.ts +++ b/src/dev/build/tasks/os_packages/create_os_package_tasks.test.ts @@ -32,6 +32,7 @@ async function setup() { linux: false, linuxArm: false, darwin: false, + windows: false, }, }); diff --git a/src/dev/build/tasks/os_packages/docker_generator/run.ts b/src/dev/build/tasks/os_packages/docker_generator/run.ts index ab190b110129..e1958edacebe 100644 --- a/src/dev/build/tasks/os_packages/docker_generator/run.ts +++ b/src/dev/build/tasks/os_packages/docker_generator/run.ts @@ -93,7 +93,7 @@ export async function runDockerGenerator( await accessAsync(resolve(artifactsDir, artifactTarball)); await mkdirp(dockerBuildDir); await unlinkAsync(resolve(dockerBuildDir, artifactTarball)); - } catch (e) { + } catch (e: any) { if (e && e.code === 'ENOENT' && e.syscall === 'access') { throw new Error( `OpenSearch Dashboards linux target (${artifactTarball}) is needed in order to build ${''}the docker image. None was found at ${artifactsDir}` diff --git a/src/dev/build/tasks/patch_native_modules_task.test.ts b/src/dev/build/tasks/patch_native_modules_task.test.ts index 25bb49e06ee0..311bf28262fa 100644 --- a/src/dev/build/tasks/patch_native_modules_task.test.ts +++ b/src/dev/build/tasks/patch_native_modules_task.test.ts @@ -30,7 +30,7 @@ const { untar } = jest.requireMock('../lib/fs'); const { gunzip } = jest.requireMock('../lib/fs'); const { download } = jest.requireMock('../lib/download'); -async function setup() { +async function setup(targetPlatforms: any) { const config = await Config.create({ isRelease: true, targetAllPlatforms: false, @@ -38,6 +38,8 @@ async function setup() { linux: false, linuxArm: false, darwin: false, + windows: false, + ...targetPlatforms, }, }); @@ -56,8 +58,7 @@ beforeEach(() => { }); it('patch native modules task downloads the correct platform package', async () => { - const { config, build } = await setup(); - config.targetPlatforms.linuxArm = true; + const { config, build } = await setup({ linuxArm: true }); await PatchNativeModules.run(config, log, build); expect(download.mock.calls.length).toBe(1); expect(download.mock.calls).toMatchInlineSnapshot(` @@ -76,16 +77,14 @@ it('patch native modules task downloads the correct platform package', async () }); it('for .tar.gz artifact, patch native modules task unzip it via untar', async () => { - const { config, build } = await setup(); - config.targetPlatforms.linuxArm = true; + const { config, build } = await setup({ linuxArm: true }); await PatchNativeModules.run(config, log, build); expect(untar.mock.calls.length).toBe(1); expect(gunzip.mock.calls.length).toBe(0); }); it('for .gz artifact, patch native modules task unzip it via gunzip', async () => { - const { config, build } = await setup(); - config.targetPlatforms.linux = true; + const { config, build } = await setup({ linux: true }); await PatchNativeModules.run(config, log, build); expect(untar.mock.calls.length).toBe(0); expect(gunzip.mock.calls.length).toBe(1); diff --git a/src/dev/i18n/integrate_locale_files.test.ts b/src/dev/i18n/integrate_locale_files.test.ts index f11419868faa..96b53276b04a 100644 --- a/src/dev/i18n/integrate_locale_files.test.ts +++ b/src/dev/i18n/integrate_locale_files.test.ts @@ -35,7 +35,7 @@ import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files'; import { relativeToRepoRoot, standardize } from '@osd/cross-platform'; const currentDir = relativeToRepoRoot(__dirname); -const localePath = resolve(currentDir, '__fixtures__', 'integrate_locale_files', 'fr.json'); +const localePath = resolve(currentDir || '', '__fixtures__', 'integrate_locale_files', 'fr.json'); const mockDefaultMessagesMap = new Map([ ['plugin-1.message-id-1', { message: 'Message text 1' }], @@ -181,11 +181,11 @@ Map { const [[path1, json1], [path2, json2]] = mockWriteFileAsync.mock.calls; const [[dirPath1], [dirPath2]] = mockMakeDirAsync.mock.calls; - expect([standardize(relativeToRepoRoot(path1)), json1]).toMatchSnapshot(); - expect([standardize(relativeToRepoRoot(path2)), json2]).toMatchSnapshot(); + expect([standardize(relativeToRepoRoot(path1) || ''), json1]).toMatchSnapshot(); + expect([standardize(relativeToRepoRoot(path2) || ''), json2]).toMatchSnapshot(); expect([ - standardize(relativeToRepoRoot(dirPath1)), - standardize(relativeToRepoRoot(dirPath2)), + standardize(relativeToRepoRoot(dirPath1) || ''), + standardize(relativeToRepoRoot(dirPath2) || ''), ]).toMatchSnapshot(); }); }); diff --git a/src/dev/i18n/integrate_locale_files.ts b/src/dev/i18n/integrate_locale_files.ts index 2a362214d6d8..b210b09bd033 100644 --- a/src/dev/i18n/integrate_locale_files.ts +++ b/src/dev/i18n/integrate_locale_files.ts @@ -106,7 +106,7 @@ export function verifyMessages( typeof message === 'string' ? message : message.text, messageId ); - } catch (err) { + } catch (err: any) { if (options.ignoreIncompatible) { localizedMessagesMap.delete(messageId); options.log.warning(`Incompatible translation ignored: ${err.message}`); @@ -123,7 +123,7 @@ export function verifyMessages( try { const message = localizedMessagesMap.get(messageId)!; verifyICUMessage(typeof message === 'string' ? message : message?.text); - } catch (err) { + } catch (err: any) { if (options.ignoreMalformed) { localizedMessagesMap.delete(messageId); options.log.warning(`Malformed translation ignored (${messageId}): ${err}`); diff --git a/src/dev/i18n/tasks/check_configs.ts b/src/dev/i18n/tasks/check_configs.ts index df57c874f258..62b5cb25c9c4 100644 --- a/src/dev/i18n/tasks/check_configs.ts +++ b/src/dev/i18n/tasks/check_configs.ts @@ -42,7 +42,7 @@ export function checkConfigs(additionalConfigPaths: string | string[] = []) { task: async (context: { reporter: ErrorReporter }) => { try { await checkConfigNamespacePrefix(configPath); - } catch (err) { + } catch (err: any) { const { reporter } = context; const reporterWithContext = reporter.withContext({ name: configPath }); reporterWithContext.report(err); diff --git a/src/dev/i18n/tasks/merge_configs.ts b/src/dev/i18n/tasks/merge_configs.ts index 83e94d4da6f6..d54f91f2b7b8 100644 --- a/src/dev/i18n/tasks/merge_configs.ts +++ b/src/dev/i18n/tasks/merge_configs.ts @@ -41,7 +41,7 @@ export function mergeConfigs(additionalConfigPaths: string | string[] = []) { task: async (context: { reporter: ErrorReporter; config?: I18nConfig }) => { try { context.config = await assignConfigFromPath(context.config, configPath); - } catch (err) { + } catch (err: any) { const { reporter } = context; const reporterWithContext = reporter.withContext({ name: configPath }); reporterWithContext.report(err); diff --git a/src/dev/i18n/utils/verify_icu_message.ts b/src/dev/i18n/utils/verify_icu_message.ts index 0470cac4ea1f..752ae37b1801 100644 --- a/src/dev/i18n/utils/verify_icu_message.ts +++ b/src/dev/i18n/utils/verify_icu_message.ts @@ -70,7 +70,7 @@ export function verifyICUMessage(message: string) { verifySelectFormatNode(node.format); } } - } catch (error) { + } catch (error: any) { if (error.name === 'SyntaxError') { const errorWithContext = createParserErrorMessage(message, { loc: { diff --git a/src/dev/npm/installed_packages.ts b/src/dev/npm/installed_packages.ts index d00ed9c8b0af..982a4dc9cba2 100644 --- a/src/dev/npm/installed_packages.ts +++ b/src/dev/npm/installed_packages.ts @@ -58,7 +58,7 @@ function resolveLicenses( throw new Error('no license field'); } return [pkg.license as string]; - } catch (error) { + } catch (error: any) { throw new Error( `Unable to detect license for \`"private": true\` package at ${realPath}: ${error.message}` ); diff --git a/src/dev/prs/github_api.ts b/src/dev/prs/github_api.ts index 425c9a9461a7..5e493a81743b 100644 --- a/src/dev/prs/github_api.ts +++ b/src/dev/prs/github_api.ts @@ -79,7 +79,7 @@ export class GithubApi { owner, sourceBranch, }; - } catch (error) { + } catch (error: any) { if (!isRateLimitError(error)) { throw error; } diff --git a/src/dev/prs/run_update_prs_cli.ts b/src/dev/prs/run_update_prs_cli.ts index 2e5f14c04b7b..cec394442250 100644 --- a/src/dev/prs/run_update_prs_cli.ts +++ b/src/dev/prs/run_update_prs_cli.ts @@ -83,7 +83,7 @@ run( await Promise.all([ proc.then(() => log.debug(` - ${cmd} exited with 0`)), - Rx.merge(getLine$(proc.stdout), getLine$(proc.stderr)) + Rx.merge(getLine$(proc.stdout!), getLine$(proc.stderr!)) .pipe(tap((line) => log.debug(line))) .toPromise(), ]); @@ -96,7 +96,7 @@ run( try { // attempt to init upstream remote await execInDir('git', ['remote', 'add', 'upstream', UPSTREAM_URL]); - } catch (error) { + } catch (error: any) { if (error.exitCode !== 128) { throw error; } @@ -123,7 +123,7 @@ run( try { log.info('Pulling in changes from opensearch:%s', pr.targetRef); await execInDir('git', ['pull', 'upstream', pr.targetRef, '--no-edit']); - } catch (error) { + } catch (error: any) { if (!error.stdout.includes('Automatic merge failed;')) { throw error; } diff --git a/src/dev/run_check_published_api_changes.ts b/src/dev/run_check_published_api_changes.ts index f17df85422b2..4c48c19f2c0c 100644 --- a/src/dev/run_check_published_api_changes.ts +++ b/src/dev/run_check_published_api_changes.ts @@ -205,7 +205,7 @@ async function run(folder: string, { opts }: { opts: Options }): Promise = new Map(); await list.run({ messages, reporter }); - } catch (error) { + } catch (error: any) { process.exitCode = 1; if (error instanceof ErrorReporter) { error.errors.forEach((e: string | Error) => log.error(e)); diff --git a/src/dev/run_i18n_extract.ts b/src/dev/run_i18n_extract.ts index 28c49c3ab868..4eb13d8d02ec 100644 --- a/src/dev/run_i18n_extract.ts +++ b/src/dev/run_i18n_extract.ts @@ -90,7 +90,7 @@ run( const reporter = new ErrorReporter(); const messages: Map = new Map(); await list.run({ messages, reporter }); - } catch (error) { + } catch (error: any) { process.exitCode = 1; if (error instanceof ErrorReporter) { error.errors.forEach((e: string | Error) => log.error(e)); diff --git a/src/dev/run_i18n_integrate.ts b/src/dev/run_i18n_integrate.ts index 70c5d82422d2..56e7888416c7 100644 --- a/src/dev/run_i18n_integrate.ts +++ b/src/dev/run_i18n_integrate.ts @@ -123,7 +123,7 @@ run( const messages: Map = new Map(); await list.run({ messages, reporter }); process.exitCode = 0; - } catch (error) { + } catch (error: any) { process.exitCode = 1; if (error instanceof ErrorReporter) { error.errors.forEach((e: string | Error) => log.error(e)); diff --git a/src/dev/typescript/build_refs.ts b/src/dev/typescript/build_refs.ts index 1a7601be04ce..09bc5e440cb5 100644 --- a/src/dev/typescript/build_refs.ts +++ b/src/dev/typescript/build_refs.ts @@ -39,7 +39,7 @@ async function buildRefs(log: ToolingLog, projectPath: string) { try { log.debug(`Building TypeScript projects refs for ${projectPath}...`); await execa(require.resolve('typescript/bin/tsc'), ['-b', projectPath, '--pretty']); - } catch (e) { + } catch (e: any) { log.error(e); process.exit(1); } diff --git a/src/fixtures/telemetry_collectors/working_collector.ts b/src/fixtures/telemetry_collectors/working_collector.ts index f021db623ae7..836a85b95f3f 100644 --- a/src/fixtures/telemetry_collectors/working_collector.ts +++ b/src/fixtures/telemetry_collectors/working_collector.ts @@ -79,7 +79,7 @@ export const myCollector = makeUsageCollector({ ], my_str_array: ['hello', 'world'], }; - } catch (err) { + } catch (err: any) { return { my_objects: { total: 0, diff --git a/src/legacy/server/i18n/get_translations_path.ts b/src/legacy/server/i18n/get_translations_path.ts index e06e3a9b675a..3e81c3b88b68 100644 --- a/src/legacy/server/i18n/get_translations_path.ts +++ b/src/legacy/server/i18n/get_translations_path.ts @@ -55,7 +55,7 @@ export async function getTranslationPaths({ cwd, glob }: { cwd: string; glob: st translationPaths.push(translationFullPath); }); } - } catch (err) { + } catch (err: any) { throw new Error(`Failed to parse .i18nrc.json file at ${entryFullPath}`); } } diff --git a/src/legacy/server/i18n/localization/file_integrity.ts b/src/legacy/server/i18n/localization/file_integrity.ts index dbacd74f25d6..3f182e7ba3ea 100644 --- a/src/legacy/server/i18n/localization/file_integrity.ts +++ b/src/legacy/server/i18n/localization/file_integrity.ts @@ -57,7 +57,7 @@ export async function getIntegrityHash(filepath: string): Promise { return data.toString('hex'); } return data; - } catch (err) { + } catch (err: any) { return null; } } diff --git a/src/legacy/utils/version.ts b/src/legacy/utils/version.ts index c9b06a775113..cad80b0281bf 100644 --- a/src/legacy/utils/version.ts +++ b/src/legacy/utils/version.ts @@ -31,7 +31,7 @@ export function versionSatisfies(cleanActual: string, cleanExpected: string) { try { return cleanActual === cleanExpected; - } catch (err) { + } catch (err: any) { return false; } } diff --git a/src/optimize/bundles_route/dynamic_asset_response.ts b/src/optimize/bundles_route/dynamic_asset_response.ts index b201fe039b6d..314792ec481d 100644 --- a/src/optimize/bundles_route/dynamic_asset_response.ts +++ b/src/optimize/bundles_route/dynamic_asset_response.ts @@ -50,7 +50,7 @@ const asyncFstat = promisify(Fs.fstat); async function tryToOpenFile(filePath: string) { try { return await asyncOpen(filePath, 'r'); - } catch (e) { + } catch (e: any) { if (e.code === 'ENOENT') { return undefined; } else { @@ -160,7 +160,7 @@ export async function createDynamicAssetResponse({ } return response; - } catch (error) { + } catch (error: any) { if (fd) { try { await asyncClose(fd); 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 c21c81cafa28..1558c524132a 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 @@ -160,7 +160,7 @@ export class Field extends PureComponent { newUnsavedValue = value.trim() || (isJsonArray ? '[]' : '{}'); try { JSON.parse(newUnsavedValue); - } catch (e) { + } catch (e: any) { errorParams = { error: i18n.translate('advancedSettings.field.codeEditorSyntaxErrorMessage', { defaultMessage: 'Invalid JSON syntax', @@ -258,7 +258,7 @@ export class Field extends PureComponent { value: base64Image, ...errorParams, }); - } catch (err) { + } catch (err: any) { this.props.toasts.addDanger( i18n.translate('advancedSettings.field.imageChangeErrorMessage', { defaultMessage: 'Image could not be saved', @@ -268,7 +268,7 @@ export class Field extends PureComponent { } }; - async getImageAsBase64(file: Blob): Promise { + async getImageAsBase64(file: Blob): Promise { const reader = new FileReader(); reader.readAsDataURL(file); diff --git a/src/plugins/advanced_settings/public/management_app/components/form/form.tsx b/src/plugins/advanced_settings/public/management_app/components/form/form.tsx index 92b7a792d2d2..9764e7d1085c 100644 --- a/src/plugins/advanced_settings/public/management_app/components/form/form.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/form/form.tsx @@ -189,7 +189,7 @@ export class Form extends PureComponent { if (requiresReload) { this.renderPageReloadToast(); } - } catch (e) { + } catch (e: any) { this.props.toasts.addDanger( i18n.translate('advancedSettings.form.saveErrorMessage', { defaultMessage: 'Unable to save', 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 2e80bc4048c5..436884db6617 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 @@ -41,7 +41,7 @@ const getPromiseState = (promise: Promise): Promise<'resolved' | 'rejec () => resolve('rejected') ) ), - new Promise<'pending'>((resolve) => resolve()).then(() => 'pending'), + new Promise<'pending' | void>((resolve) => resolve()).then(() => 'pending'), ]); const isPending = (promise: Promise): Promise => diff --git a/src/plugins/bfetch/public/batching/create_streaming_batched_function.ts b/src/plugins/bfetch/public/batching/create_streaming_batched_function.ts index 67d938e1eb22..ea1b3057d742 100644 --- a/src/plugins/bfetch/public/batching/create_streaming_batched_function.ts +++ b/src/plugins/bfetch/public/batching/create_streaming_batched_function.ts @@ -139,7 +139,7 @@ export const createStreamingBatchedFunction = ( }, }); await stream.toPromise(); - } catch (error) { + } catch (error: any) { for (const item of items) item.future.reject(error); } }, diff --git a/src/plugins/bfetch/server/plugin.ts b/src/plugins/bfetch/server/plugin.ts index 1e34d146b27f..a6cf805c8941 100644 --- a/src/plugins/bfetch/server/plugin.ts +++ b/src/plugins/bfetch/server/plugin.ts @@ -211,7 +211,7 @@ export class BfetchServerPlugin try { const result = await handlerInstance.onBatchItem(batchItem); subject.next({ id, result }); - } catch (err) { + } catch (err: any) { const error = normalizeError(err); subject.next({ id, error }); } finally { diff --git a/src/plugins/bfetch/server/streaming/create_ndjson_stream.ts b/src/plugins/bfetch/server/streaming/create_ndjson_stream.ts index 6c7c29ae0047..1843bf6ccb4e 100644 --- a/src/plugins/bfetch/server/streaming/create_ndjson_stream.ts +++ b/src/plugins/bfetch/server/streaming/create_ndjson_stream.ts @@ -45,7 +45,7 @@ export const createNDJSONStream = ( try { const line = JSON.stringify(message); stream.write(`${line}${delimiter}`); - } catch (error) { + } catch (error: any) { logger.error('Could not serialize or stream a message.'); logger.error(error); } diff --git a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx index 35fc2fc60a2e..34ce3dff73d2 100644 --- a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -176,7 +176,7 @@ function EditorUI({ initialTextValue }: EditorProps) { try { const content = editor.getCoreEditor().getValue(); saveCurrentTextObject(content); - } catch (e) { + } catch (e: any) { // Ignoring saving error } } diff --git a/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts b/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts index b9be1c56d912..02490093a1fa 100644 --- a/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts +++ b/src/plugins/console/public/application/hooks/use_data_init/use_data_init.ts @@ -69,7 +69,7 @@ export const useDataInit = () => { payload: results.sort((a, b) => a.createdAt - b.createdAt)[0], }); } - } catch (e) { + } catch (e: any) { setError(e); } finally { setDone(true); diff --git a/src/plugins/console/public/application/hooks/use_send_current_request_to_opensearch/use_send_current_request_to_opensearch.ts b/src/plugins/console/public/application/hooks/use_send_current_request_to_opensearch/use_send_current_request_to_opensearch.ts index e5c9e7f2d2d1..4b3cf7b02645 100644 --- a/src/plugins/console/public/application/hooks/use_send_current_request_to_opensearch/use_send_current_request_to_opensearch.ts +++ b/src/plugins/console/public/application/hooks/use_send_current_request_to_opensearch/use_send_current_request_to_opensearch.ts @@ -69,7 +69,7 @@ export const useSendCurrentRequestToOpenSearch = () => { results.forEach(({ request: { path, method, data } }) => { try { history.addToHistory(path, method, data); - } catch (e) { + } catch (e: any) { // Best effort, but notify the user. notifications.toasts.addError(e, { title: i18n.translate('console.notification.error.couldNotSaveRequestTitle', { @@ -94,7 +94,7 @@ export const useSendCurrentRequestToOpenSearch = () => { data: results, }, }); - } catch (e) { + } catch (e: any) { if (e?.response) { dispatch({ type: 'requestFail', 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 55ee5fe2a343..2413c6eab811 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 @@ -250,7 +250,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/public/lib/autocomplete/autocomplete.ts b/src/plugins/console/public/lib/autocomplete/autocomplete.ts index 427578b0f8e0..1873d1dc54f1 100644 --- a/src/plugins/console/public/lib/autocomplete/autocomplete.ts +++ b/src/plugins/console/public/lib/autocomplete/autocomplete.ts @@ -1019,7 +1019,7 @@ export default function ({ coreEditor: editor, parser }: { coreEditor: CoreEdito }) ); } - } catch (e) { + } catch (e: any) { // eslint-disable-next-line no-console console.error(e); callback(e, null); diff --git a/src/plugins/console/public/lib/utils/index.ts b/src/plugins/console/public/lib/utils/index.ts index 93a0688ae725..f9c14efbebd0 100644 --- a/src/plugins/console/public/lib/utils/index.ts +++ b/src/plugins/console/public/lib/utils/index.ts @@ -57,7 +57,7 @@ export function formatRequestBodyDoc(data: string[], indent: boolean) { } changed = changed || newDoc !== curDoc; formattedData.push(newDoc); - } catch (e) { + } catch (e: any) { // eslint-disable-next-line no-console console.log(e); formattedData.push(curDoc); diff --git a/src/plugins/console/server/lib/proxy_request.test.ts b/src/plugins/console/server/lib/proxy_request.test.ts index 8b2d05eac6fe..04a572ade279 100644 --- a/src/plugins/console/server/lib/proxy_request.test.ts +++ b/src/plugins/console/server/lib/proxy_request.test.ts @@ -67,7 +67,7 @@ describe(`Console's send request`, () => { uri: new URL('http://noone.nowhere.none'), }); fail('Should not reach here!'); - } catch (e) { + } catch (e: any) { const { message } = e as Error; expect(message).toEqual('Client request timeout'); expect((fakeRequest.abort as sinon.SinonStub).calledOnce).toBe(true); diff --git a/src/plugins/console/server/routes/api/console/proxy/create_handler.ts b/src/plugins/console/server/routes/api/console/proxy/create_handler.ts index 9f564d9c8b81..786c7a8a7512 100644 --- a/src/plugins/console/server/routes/api/console/proxy/create_handler.ts +++ b/src/plugins/console/server/routes/api/console/proxy/create_handler.ts @@ -174,7 +174,7 @@ export const createHandler = ({ }); break; - } catch (e) { + } catch (e: any) { // If we reached here it means we hit a lower level network issue than just, for e.g., a 500. // We try contacting another node in that case. log.error(e); diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx index e49999383712..49b8ef4d814e 100644 --- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx +++ b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.tsx @@ -171,7 +171,7 @@ class DashboardGridUi extends React.Component { let layout; try { layout = this.buildLayoutFromPanels(); - } catch (error) { + } catch (error: any) { console.error(error); // eslint-disable-line no-console isLayoutInvalid = true; diff --git a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.tsx b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.tsx index 2a98046b4d2c..e6064167bbf7 100644 --- a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.tsx +++ b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.tsx @@ -31,7 +31,7 @@ import React from 'react'; import { Subscription } from 'rxjs'; import { PanelState, EmbeddableStart } from '../../../embeddable_plugin'; -import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container'; +import { DashboardContainer } from '../dashboard_container'; import { DashboardGrid } from '../grid'; import { context } from '../../../../../opensearch_dashboards_react/public'; @@ -54,7 +54,6 @@ interface State { export class DashboardViewport extends React.Component { static contextType = context; - public readonly context!: DashboardReactContextValue; private subscription?: Subscription; private mounted: boolean = false; constructor(props: DashboardViewportProps) { diff --git a/src/plugins/dashboard/public/attribute_service/attribute_service.tsx b/src/plugins/dashboard/public/attribute_service/attribute_service.tsx index 2588793fe7f7..faeaf4f33bda 100644 --- a/src/plugins/dashboard/public/attribute_service/attribute_service.tsx +++ b/src/plugins/dashboard/public/attribute_service/attribute_service.tsx @@ -121,7 +121,7 @@ export class AttributeService< return { ...originalInput, savedObjectId: savedItem.id } as RefType; } return { ...originalInput } as RefType; - } catch (error) { + } catch (error: any) { this.toasts.addDanger({ title: i18n.translate('dashboard.attributeService.saveToLibraryError', { defaultMessage: `An error occurred while saving. Error: {errorMessage}`, @@ -179,7 +179,7 @@ export class AttributeService< // Combine input and wrapped input to preserve any passed in explicit Input. resolve({ ...input, ...wrappedInput }); return { id: wrappedInput.savedObjectId }; - } catch (error) { + } catch (error: any) { reject(error); return { error }; } diff --git a/src/plugins/dashboard/public/url_generator.ts b/src/plugins/dashboard/public/url_generator.ts index 969af33c9253..c7529dab8253 100644 --- a/src/plugins/dashboard/public/url_generator.ts +++ b/src/plugins/dashboard/public/url_generator.ts @@ -112,7 +112,7 @@ export const createDashboardUrlGenerator = ( try { const dashboard = await startServices.savedDashboardLoader.get(state.dashboardId); return dashboard?.searchSource?.getField('filter') ?? []; - } catch (e) { + } catch (e: any) { // in case dashboard is missing, built the url without those filters // dashboard app will handle redirect to landing page with toast message return []; diff --git a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts index 0220fbe798f2..8753865f2ea8 100644 --- a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts +++ b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts @@ -43,7 +43,7 @@ function migrateIndexPattern(doc: DashboardDoc700To720) { let searchSource; try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return; } @@ -87,7 +87,7 @@ const migrations700: SavedObjectMigrationFn = (doc): DashboardDoc700To let panels; try { panels = JSON.parse(panelsJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc as DashboardDoc700To720; } diff --git a/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts b/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts index 8275d2206b0e..db6af8eab960 100644 --- a/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts +++ b/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts @@ -46,7 +46,7 @@ export const migrateMatchAllQuery: SavedObjectMigrationFn = (doc) => { try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc; } diff --git a/src/plugins/dashboard/server/saved_objects/migrations_730.ts b/src/plugins/dashboard/server/saved_objects/migrations_730.ts index 4d7000a13724..b321c6287e7d 100644 --- a/src/plugins/dashboard/server/saved_objects/migrations_730.ts +++ b/src/plugins/dashboard/server/saved_objects/migrations_730.ts @@ -47,7 +47,7 @@ export const migrations730 = (doc: DashboardDoc700To720, { log }: SavedObjectMig doc.attributes.kibanaSavedObjectMeta.searchSourceJSON = JSON.stringify( moveFiltersToQuery(searchSource) ); - } catch (e) { + } catch (e: any) { log.warning( `Exception @ migrations730 while trying to migrate dashboard query filters!\n` + `${e.stack}\n` + @@ -74,7 +74,7 @@ export const migrations730 = (doc: DashboardDoc700To720, { log }: SavedObjectMig ); delete doc.attributes.uiStateJSON; - } catch (e) { + } catch (e: any) { log.warning( `Exception @ migrations730 while trying to migrate dashboard panels!\n` + `Error: ${e.stack}\n` + diff --git a/src/plugins/data/common/field_formats/converters/string.ts b/src/plugins/data/common/field_formats/converters/string.ts index 3a3bf301b357..37822a3dd4e5 100644 --- a/src/plugins/data/common/field_formats/converters/string.ts +++ b/src/plugins/data/common/field_formats/converters/string.ts @@ -110,7 +110,7 @@ export class StringFormat extends FieldFormat { private base64Decode(val: string) { try { return Buffer.from(val, 'base64').toString('utf8'); - } catch (e) { + } catch (e: any) { return asPrettyString(val); } } diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts index 089927dbc1e8..bb933a309f77 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts @@ -234,7 +234,7 @@ describe('IndexPattern', () => { expect.assertions(1); try { await indexPattern.addScriptedField(scriptedField.name, "'new script'", 'string'); - } catch (e) { + } catch (e: any) { expect(e).toBeInstanceOf(DuplicateField); } }); diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts index 5e4d80df6ccd..805545dbf698 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts @@ -158,7 +158,7 @@ export class IndexPattern implements IIndexPattern { private deserializeFieldFormatMap(mapping: SerializedFieldFormat>) { try { return this.fieldFormats.getInstance(mapping.id as string, mapping.params); - } catch (err) { + } catch (err: any) { if (err instanceof FieldFormatNotFoundError) { return undefined; } else { diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts index 4361e12dec16..affcdaf3a3a8 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.test.ts @@ -175,7 +175,7 @@ describe('IndexPatterns', () => { let result; try { await indexPatterns.updateSavedObject(samePattern); - } catch (err) { + } catch (err: any) { result = err; } diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts index bd5bc48bba7c..ff2d5657b157 100644 --- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts +++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts @@ -266,7 +266,7 @@ export class IndexPatternsService { const fields = await this.getFieldsForIndexPattern(indexPattern); const scripted = indexPattern.getScriptedFields().map((field) => field.spec); indexPattern.fields.replaceAll([...fields, ...scripted]); - } catch (err) { + } catch (err: any) { if (err instanceof IndexPatternMissingIndices) { this.onNotification({ title: (err as any).message, color: 'danger', iconType: 'alert' }); } @@ -297,7 +297,7 @@ export class IndexPatternsService { try { const newFields = await this.getFieldsForWildcard(options); return this.fieldArrayToMap([...newFields, ...scriptdFields]); - } catch (err) { + } catch (err: any) { if (err instanceof IndexPatternMissingIndices) { this.onNotification({ title: (err as any).message, color: 'danger', iconType: 'alert' }); return {}; @@ -422,7 +422,7 @@ export class IndexPatternsService { dataSourceId: dataSourceRef?.id, }) : spec.fields; - } catch (err) { + } catch (err: any) { isSaveRequired = false; if (err instanceof IndexPatternMissingIndices) { this.onNotification({ @@ -452,7 +452,7 @@ export class IndexPatternsService { if (isSaveRequired) { try { this.updateSavedObject(indexPattern); - } catch (err) { + } catch (err: any) { this.onError(err, { title: i18n.translate('data.indexPatterns.fetchFieldSaveErrorTitle', { defaultMessage: diff --git a/src/plugins/data/common/opensearch_query/kuery/ast/ast.ts b/src/plugins/data/common/opensearch_query/kuery/ast/ast.ts index 57003e445bc5..3f9f8dc68f5e 100644 --- a/src/plugins/data/common/opensearch_query/kuery/ast/ast.ts +++ b/src/plugins/data/common/opensearch_query/kuery/ast/ast.ts @@ -69,7 +69,7 @@ export const fromKueryExpression = ( ): KueryNode => { try { return fromExpression(expression, parseOptions, parseKuery); - } catch (error) { + } catch (error: any) { if (error.name === 'SyntaxError') { throw new DQLSyntaxError(error, expression); } else { @@ -84,7 +84,7 @@ export const doesKueryExpressionHaveLuceneSyntaxError = ( try { fromExpression(expression, { errorOnLuceneSyntax: true }, parseKuery); return false; - } catch (e) { + } catch (e: any) { return e.message.startsWith('Lucene'); } }; diff --git a/src/plugins/data/common/search/aggs/param_types/json.ts b/src/plugins/data/common/search/aggs/param_types/json.ts index a1daf76fcf5b..897280fae587 100644 --- a/src/plugins/data/common/search/aggs/param_types/json.ts +++ b/src/plugins/data/common/search/aggs/param_types/json.ts @@ -51,7 +51,7 @@ export class JsonParamType extends BaseParamType { // handle invalid Json input try { paramJson = JSON.parse(param); - } catch (err) { + } catch (err: any) { return; } diff --git a/src/plugins/data/common/search/aggs/utils/date_interval_utils/is_valid_interval.ts b/src/plugins/data/common/search/aggs/utils/date_interval_utils/is_valid_interval.ts index bc52418e2519..2e54e1fa675c 100644 --- a/src/plugins/data/common/search/aggs/utils/date_interval_utils/is_valid_interval.ts +++ b/src/plugins/data/common/search/aggs/utils/date_interval_utils/is_valid_interval.ts @@ -38,7 +38,7 @@ function parseWithBase(value: string, baseInterval: string) { try { const interval = leastCommonInterval(baseInterval, value); return interval === value.replace(/\s/g, ''); - } catch (e) { + } catch (e: any) { return false; } } diff --git a/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_interval.ts b/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_interval.ts index 3e46e2a65530..ee7bdfe3f662 100644 --- a/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_interval.ts +++ b/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_interval.ts @@ -66,7 +66,7 @@ export function parseInterval(interval: string): moment.Duration | null { } return moment.duration(duration.as(selectedUnit), selectedUnit); - } catch (e) { + } catch (e: any) { return null; } } diff --git a/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_opensearch_interval.test.ts b/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_opensearch_interval.test.ts index 7009e12fce80..2f5571b94598 100644 --- a/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_opensearch_interval.test.ts +++ b/src/plugins/data/common/search/aggs/utils/date_interval_utils/parse_opensearch_interval.test.ts @@ -59,7 +59,7 @@ describe('parseOpenSearchInterval', () => { intervals.forEach((interval) => { try { parseOpenSearchInterval(interval); - } catch (error) { + } catch (error: any) { expect(error instanceof InvalidOpenSearchCalendarIntervalError).toBe(true); } }); @@ -72,7 +72,7 @@ describe('parseOpenSearchInterval', () => { intervals.forEach((interval) => { try { parseOpenSearchInterval(interval); - } catch (error) { + } catch (error: any) { expect(error instanceof InvalidOpenSearchIntervalFormatError).toBe(true); } }); diff --git a/src/plugins/data/common/search/aggs/utils/get_parsed_value.ts b/src/plugins/data/common/search/aggs/utils/get_parsed_value.ts index 1b7099752a6c..e607e149cd6a 100644 --- a/src/plugins/data/common/search/aggs/utils/get_parsed_value.ts +++ b/src/plugins/data/common/search/aggs/utils/get_parsed_value.ts @@ -39,7 +39,7 @@ export const getParsedValue = (data: any, key: string) => { try { return data[key] ? JSON.parse(data[key]) : undefined; - } catch (e) { + } catch (e: any) { throw new Error(`Unable to parse ${key} argument string`); } }; diff --git a/src/plugins/data/common/search/search_source/mocks.ts b/src/plugins/data/common/search/search_source/mocks.ts index 959d1aebfe53..56f449f4cc08 100644 --- a/src/plugins/data/common/search/search_source/mocks.ts +++ b/src/plugins/data/common/search/search_source/mocks.ts @@ -54,6 +54,7 @@ export const searchSourceInstanceMock: MockedKeys = { history: [], getSerializedFields: jest.fn(), serialize: jest.fn(), + flatten: jest.fn(), }; export const searchSourceCommonMock: jest.Mocked = { diff --git a/src/plugins/data/common/search/search_source/parse_json.ts b/src/plugins/data/common/search/search_source/parse_json.ts index 80a58d62ff7f..8612ea170059 100644 --- a/src/plugins/data/common/search/search_source/parse_json.ts +++ b/src/plugins/data/common/search/search_source/parse_json.ts @@ -36,7 +36,7 @@ export const parseSearchSourceJSON = (searchSourceJSON: string) => { let searchSourceValues: SearchSourceFields; try { searchSourceValues = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { throw new InvalidJSONProperty( `Invalid JSON in search source. ${e.message} JSON: ${searchSourceJSON}` ); diff --git a/src/plugins/data/common/search/tabify/get_columns.ts b/src/plugins/data/common/search/tabify/get_columns.ts index 25ea25703edb..bcf08820d11a 100644 --- a/src/plugins/data/common/search/tabify/get_columns.ts +++ b/src/plugins/data/common/search/tabify/get_columns.ts @@ -36,7 +36,7 @@ const getColumn = (agg: IAggConfig, i: number): TabbedAggColumn => { let name = ''; try { name = agg.makeLabel(); - } catch (e) { + } catch (e: any) { // skip the case when makeLabel throws an error (e.x. no appropriate field for an aggregation) } diff --git a/src/plugins/data/public/actions/select_range_action.ts b/src/plugins/data/public/actions/select_range_action.ts index a664c2d53472..f51dca0c3ead 100644 --- a/src/plugins/data/public/actions/select_range_action.ts +++ b/src/plugins/data/public/actions/select_range_action.ts @@ -58,7 +58,7 @@ export function createSelectRangeAction( timeFieldName: context.data.timeFieldName, }); } - } catch (e) { + } catch (e: any) { // eslint-disable-next-line no-console console.warn(`Error [ACTION_SELECT_RANGE]: can\'t extract filters from action context`); } diff --git a/src/plugins/data/public/actions/value_click_action.ts b/src/plugins/data/public/actions/value_click_action.ts index 2da90f8adaa5..5af0c65779a4 100644 --- a/src/plugins/data/public/actions/value_click_action.ts +++ b/src/plugins/data/public/actions/value_click_action.ts @@ -58,7 +58,7 @@ export function createValueClickAction( timeFieldName: context.data.timeFieldName, }); } - } catch (e) { + } catch (e: any) { // eslint-disable-next-line no-console console.warn( `Error [ACTION_EMIT_APPLY_FILTER_TRIGGER]: can\'t extract filters from action context` diff --git a/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts b/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts index 2c8a8f7fa22f..b30c03ed4738 100644 --- a/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/generate_mapping_chain.test.ts @@ -117,7 +117,7 @@ describe('filter manager utilities', () => { try { chain(filter); - } catch (err) { + } catch (err: any) { expect(err).toBeInstanceOf(Error); expect(err.message).toBe('No mappings have been found for filter.'); done(); diff --git a/src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts b/src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts index 98544c1da268..4efa0e0b795d 100644 --- a/src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/map_filter.test.ts @@ -95,7 +95,7 @@ describe('filter manager utilities', () => { try { mapFilter(before as Filter); - } catch (e) { + } catch (e: any) { expect(e).toBeInstanceOf(Error); expect(e.message).toBe('No mappings have been found for filter.'); diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts index 83132a003f1b..cbff78641865 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_default.test.ts @@ -46,7 +46,7 @@ describe('filter manager utilities', () => { try { mapDefault(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); } }); diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts index babecb7d8037..d37fefdc00c2 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_exists.test.ts @@ -60,7 +60,7 @@ describe('filter manager utilities', () => { try { mapQueryString(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts index 79248b589f21..3488ca2c9cd6 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_bounding_box.test.ts @@ -98,7 +98,7 @@ describe('filter manager utilities', () => { try { mapGeoBoundingBox(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts index e9b1b2ec816f..85b2af149584 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_geo_polygon.test.ts @@ -89,7 +89,7 @@ describe('filter manager utilities', () => { try { mapGeoPolygon(wrongFilter); - } catch (e) { + } catch (e: any) { expect(e).toBe(wrongFilter); done(); diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts index 04b5846811ff..8e4f16f60375 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_match_all.test.ts @@ -54,7 +54,7 @@ describe('filter_manager/lib', () => { try { mapMatchAll(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts index 5bb617e0cc69..51acf3fcae8c 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_missing.test.ts @@ -49,7 +49,7 @@ describe('filter manager utilities', () => { try { mapMissing(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts index c9773d5aed8e..7cb001763e5d 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_phrase.test.ts @@ -58,7 +58,7 @@ describe('filter manager utilities', () => { try { mapPhrase(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts index 81b15ceb4df5..a039eaf02746 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_query_string.test.ts @@ -46,7 +46,7 @@ describe('filter manager utilities', () => { try { mapQueryString(filter as Filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); } diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts index b7b78dac0334..94a371b4383e 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_range.test.ts @@ -56,7 +56,7 @@ describe('filter manager utilities', () => { try { mapRange(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); diff --git a/src/plugins/data/public/query/filter_manager/lib/mappers/map_spatial_filter.test.ts b/src/plugins/data/public/query/filter_manager/lib/mappers/map_spatial_filter.test.ts index 06cd6196f2fb..bc37037d3c96 100644 --- a/src/plugins/data/public/query/filter_manager/lib/mappers/map_spatial_filter.test.ts +++ b/src/plugins/data/public/query/filter_manager/lib/mappers/map_spatial_filter.test.ts @@ -89,7 +89,7 @@ describe('mapSpatialFilter()', () => { try { mapSpatialFilter(filter); - } catch (e) { + } catch (e: any) { expect(e).toBe(filter); done(); diff --git a/src/plugins/data/public/query/lib/from_user.ts b/src/plugins/data/public/query/lib/from_user.ts index 3c6792d47d3c..16c2d80f1626 100644 --- a/src/plugins/data/public/query/lib/from_user.ts +++ b/src/plugins/data/public/query/lib/from_user.ts @@ -57,7 +57,7 @@ export function fromUser(userInput: object | string) { if (trimmedUserInput[0] === '{') { try { return JSON.parse(trimmedUserInput); - } catch (e) { + } catch (e: any) { return userInput; } } else { diff --git a/src/plugins/data/public/query/saved_query/saved_query_service.test.ts b/src/plugins/data/public/query/saved_query/saved_query_service.test.ts index 9fc8cdf61016..541faf2c0b66 100644 --- a/src/plugins/data/public/query/saved_query/saved_query_service.test.ts +++ b/src/plugins/data/public/query/saved_query/saved_query_service.test.ts @@ -161,7 +161,7 @@ describe('saved query service', () => { let error = null; try { await saveQuery(savedQueryAttributes); - } catch (e) { + } catch (e: any) { error = e; } expect(error).not.toBe(null); @@ -171,7 +171,7 @@ describe('saved query service', () => { let error = null; try { await saveQuery({ ...savedQueryAttributes, title: '' }); - } catch (e) { + } catch (e: any) { error = e; } expect(error).not.toBe(null); diff --git a/src/plugins/data/public/query/saved_query/saved_query_service.ts b/src/plugins/data/public/query/saved_query/saved_query_service.ts index ec4028756a85..34fdd8e3575c 100644 --- a/src/plugins/data/public/query/saved_query/saved_query_service.ts +++ b/src/plugins/data/public/query/saved_query/saved_query_service.ts @@ -147,7 +147,7 @@ export const createSavedQueryService = ( try { parsedQuery = JSON.parse(queryString); parsedQuery = isObject(parsedQuery) ? parsedQuery : queryString; - } catch (error) { + } catch (error: any) { parsedQuery = queryString; } diff --git a/src/plugins/data/public/search/expressions/opensearchaggs.ts b/src/plugins/data/public/search/expressions/opensearchaggs.ts index 57395b905fd5..cc2935d01c93 100644 --- a/src/plugins/data/public/search/expressions/opensearchaggs.ts +++ b/src/plugins/data/public/search/expressions/opensearchaggs.ts @@ -171,7 +171,7 @@ const handleCourierRequest = async ({ request.stats(getResponseInspectorStats(response, searchSource)).ok({ json: response }); (searchSource as any).rawResponse = response; - } catch (e) { + } catch (e: any) { // Log any error during request to the inspector request.error({ json: e }); throw e; diff --git a/src/plugins/data/public/search/expressions/opensearchdsl.test.ts b/src/plugins/data/public/search/expressions/opensearchdsl.test.ts index 4f8ecb0df429..0a8268454d01 100644 --- a/src/plugins/data/public/search/expressions/opensearchdsl.test.ts +++ b/src/plugins/data/public/search/expressions/opensearchdsl.test.ts @@ -65,7 +65,7 @@ describe('opensearchdsl', () => { let errorMessage; try { await fn(); - } catch (error) { + } catch (error: any) { errorMessage = error.message; } expect(errorMessage).toEqual('Unexpected token i in JSON at position 0'); diff --git a/src/plugins/data/public/search/expressions/opensearchdsl.ts b/src/plugins/data/public/search/expressions/opensearchdsl.ts index 5c8d8350f260..1e7b9f3e46ae 100644 --- a/src/plugins/data/public/search/expressions/opensearchdsl.ts +++ b/src/plugins/data/public/search/expressions/opensearchdsl.ts @@ -207,7 +207,7 @@ export const opensearchdsl = (): OpenSearchdslExpressionFunctionDefinition => ({ type: 'opensearch_raw_response', body: resp, }; - } catch (e) { + } catch (e: any) { request.error({ json: e }); throw e; } diff --git a/src/plugins/data/public/search/search_interceptor.test.ts b/src/plugins/data/public/search/search_interceptor.test.ts index c19e92e3872e..ba884e239c85 100644 --- a/src/plugins/data/public/search/search_interceptor.test.ts +++ b/src/plugins/data/public/search/search_interceptor.test.ts @@ -78,7 +78,7 @@ describe('SearchInterceptor', () => { try { await response.toPromise(); - } catch (e) { + } catch (e: any) { expect(e).toBe(mockResponse); } }); @@ -98,7 +98,7 @@ describe('SearchInterceptor', () => { try { await response.toPromise(); - } catch (e) { + } catch (e: any) { expect(e).toBeInstanceOf(SearchTimeoutError); expect(mockCoreSetup.notifications.toasts.addDanger).toBeCalledTimes(1); } @@ -117,7 +117,7 @@ describe('SearchInterceptor', () => { }; try { await searchInterceptor.search(mockRequest).toPromise(); - } catch (e) { + } catch (e: any) { expect(e).toBeInstanceOf(SearchTimeoutError); try { await searchInterceptor.search(mockRequest).toPromise(); @@ -154,7 +154,7 @@ describe('SearchInterceptor', () => { try { await response.toPromise(); - } catch (e) { + } catch (e: any) { expect(e).toBeInstanceOf(PainlessError); } }); diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx index 7a4bb433bd10..9334facd8ec5 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx @@ -431,7 +431,7 @@ class FilterEditorUI extends Component { if (isCustomEditorOpen) { try { return Boolean(JSON.parse(queryDsl)); - } catch (e) { + } catch (e: any) { return false; } } diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/lib/filter_editor_utils.ts b/src/plugins/data/public/ui/filter_bar/filter_editor/lib/filter_editor_utils.ts index a91813c5ca93..1f39839d5416 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/lib/filter_editor_utils.ts +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/lib/filter_editor_utils.ts @@ -70,7 +70,7 @@ export function validateParams(params: any, type: string) { return params.includes('/') ? Boolean(new CidrMask(params)) : Boolean(new Ipv4Address(params)); - } catch (e) { + } catch (e: any) { return false; } default: diff --git a/src/plugins/data/public/ui/filter_bar/filter_item.tsx b/src/plugins/data/public/ui/filter_bar/filter_item.tsx index a0631a52b53e..913062edfa7c 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_item.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_item.tsx @@ -299,7 +299,7 @@ export function FilterItem(props: Props) { } else if (isFilterApplicable()) { try { label.title = getDisplayValueFromFilter(filter, indexPatterns); - } catch (e) { + } catch (e: any) { label.status = FILTER_ITEM_ERROR; label.title = props.intl.formatMessage({ id: 'data.filter.filterBar.labelErrorText', diff --git a/src/plugins/data/public/ui/index_pattern_select/index_pattern_select.tsx b/src/plugins/data/public/ui/index_pattern_select/index_pattern_select.tsx index bcc56713f0df..e0f0123c19c9 100644 --- a/src/plugins/data/public/ui/index_pattern_select/index_pattern_select.tsx +++ b/src/plugins/data/public/ui/index_pattern_select/index_pattern_select.tsx @@ -114,7 +114,7 @@ export default class IndexPatternSelect extends Component { return fieldTypes?.includes(field.type); }); - } catch (err) { + } catch (err: any) { // Unable to parse fields JSON, invalid index pattern return false; } diff --git a/src/plugins/data/public/ui/query_string_input/query_string_input.tsx b/src/plugins/data/public/ui/query_string_input/query_string_input.tsx index 5d071748700c..2bde45d0879c 100644 --- a/src/plugins/data/public/ui/query_string_input/query_string_input.tsx +++ b/src/plugins/data/public/ui/query_string_input/query_string_input.tsx @@ -192,7 +192,7 @@ export default class QueryStringInputUI extends Component { })) || []; return [...suggestions, ...recentSearchSuggestions]; - } catch (e) { + } catch (e: any) { // TODO: Waiting on https://github.com/elastic/kibana/issues/51406 for a properly typed error // Ignore aborted requests if (e.message === 'The user aborted a request.') return; diff --git a/src/plugins/data/public/ui/search_bar/lib/use_saved_query.ts b/src/plugins/data/public/ui/search_bar/lib/use_saved_query.ts index 713b2586ebe5..036c69458b43 100644 --- a/src/plugins/data/public/ui/search_bar/lib/use_saved_query.ts +++ b/src/plugins/data/public/ui/search_bar/lib/use_saved_query.ts @@ -63,7 +63,7 @@ export const useSavedQuery = (props: UseSavedQueriesProps): UseSavedQueriesRetur setSavedQuery(newSavedQuery); populateStateFromSavedQuery(props.queryService, newSavedQuery); } - } catch (error) { + } catch (error: any) { // Clear saved query setSavedQuery(undefined); clearStateFromSavedQuery(props.queryService); diff --git a/src/plugins/data/public/ui/search_bar/search_bar.tsx b/src/plugins/data/public/ui/search_bar/search_bar.tsx index b05b18b6d64e..24e2eab51aa7 100644 --- a/src/plugins/data/public/ui/search_bar/search_bar.tsx +++ b/src/plugins/data/public/ui/search_bar/search_bar.tsx @@ -294,7 +294,7 @@ class SearchBarUI extends Component { if (this.props.onSaved) { this.props.onSaved(response); } - } catch (error) { + } catch (error: any) { this.services.notifications.toasts.addDanger( `An error occured while saving your query: ${error.message}` ); diff --git a/src/plugins/data/server/autocomplete/value_suggestions_route.ts b/src/plugins/data/server/autocomplete/value_suggestions_route.ts index 1d053d05e321..a98b5a32d65a 100644 --- a/src/plugins/data/server/autocomplete/value_suggestions_route.ts +++ b/src/plugins/data/server/autocomplete/value_suggestions_route.ts @@ -87,7 +87,7 @@ export function registerValueSuggestionsRoute( get(result, 'aggregations.nestedSuggestions.suggestions.buckets'); return response.ok({ body: map(buckets || [], 'key') }); - } catch (error) { + } catch (error: any) { return response.internalError({ body: error }); } } diff --git a/src/plugins/data/server/dql_telemetry/route.ts b/src/plugins/data/server/dql_telemetry/route.ts index 2f2f3459658d..0ce30bb45508 100644 --- a/src/plugins/data/server/dql_telemetry/route.ts +++ b/src/plugins/data/server/dql_telemetry/route.ts @@ -57,7 +57,7 @@ export function registerDqlTelemetryRoute( try { await internalRepository.incrementCounter('dql-telemetry', 'dql-telemetry', counterName); - } catch (error) { + } catch (error: any) { logger.warn(`Unable to increment counter: ${error}`); return response.customError({ statusCode: error.status, diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts b/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts index 0a33e51b1018..da65d1e9cf3a 100644 --- a/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts +++ b/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts @@ -28,7 +28,7 @@ * under the License. */ -import { LegacyAPICaller, OpenSearchClient } from 'opensearch-dashboards/server'; +import { LegacyAPICaller } from 'opensearch-dashboards/server'; import { convertOpenSearchError } from './errors'; import { FieldCapsResponse } from './field_capabilities'; @@ -66,7 +66,7 @@ export async function callIndexAliasApi( ignoreUnavailable: true, allowNoIndices: false, })) as Promise; - } catch (error) { + } catch (error: any) { throw convertOpenSearchError(indices, error); } } @@ -95,7 +95,7 @@ export async function callFieldCapsApi( ignoreUnavailable: true, ...fieldCapsOptions, })) as FieldCapsResponse; - } catch (error) { + } catch (error: any) { throw convertOpenSearchError(indices, error); } } diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/resolve_time_pattern.ts b/src/plugins/data/server/index_patterns/fetcher/lib/resolve_time_pattern.ts index c1ef0074a1d6..cff81b650204 100644 --- a/src/plugins/data/server/index_patterns/fetcher/lib/resolve_time_pattern.ts +++ b/src/plugins/data/server/index_patterns/fetcher/lib/resolve_time_pattern.ts @@ -31,7 +31,7 @@ import { chain } from 'lodash'; import moment from 'moment'; -import { LegacyAPICaller, OpenSearchClient } from 'opensearch-dashboards/server'; +import { LegacyAPICaller } from 'opensearch-dashboards/server'; import { timePatternToWildcard } from './time_pattern_to_wildcard'; import { callIndexAliasApi, IndicesAliasResponse } from './opensearch_api'; diff --git a/src/plugins/data/server/index_patterns/routes.ts b/src/plugins/data/server/index_patterns/routes.ts index 3adc1970dd81..917e52ddad59 100644 --- a/src/plugins/data/server/index_patterns/routes.ts +++ b/src/plugins/data/server/index_patterns/routes.ts @@ -69,7 +69,7 @@ export function registerRoutes(http: HttpServiceSetup) { let parsedFields: string[] = []; try { parsedFields = parseMetaFields(metaFields); - } catch (error) { + } catch (error: any) { return response.badRequest(); } @@ -85,7 +85,7 @@ export function registerRoutes(http: HttpServiceSetup) { 'content-type': 'application/json', }, }); - } catch (error) { + } catch (error: any) { if ( typeof error === 'object' && !!error?.isBoom && @@ -130,7 +130,7 @@ export function registerRoutes(http: HttpServiceSetup) { let parsedFields: string[] = []; try { parsedFields = parseMetaFields(metaFields); - } catch (error) { + } catch (error: any) { return response.badRequest(); } @@ -148,7 +148,7 @@ export function registerRoutes(http: HttpServiceSetup) { 'content-type': 'application/json', }, }); - } catch (error) { + } catch (error: any) { return response.notFound(); } } diff --git a/src/plugins/data/server/search/collectors/register.ts b/src/plugins/data/server/search/collectors/register.ts index f31cda16756d..539c66096ae8 100644 --- a/src/plugins/data/server/search/collectors/register.ts +++ b/src/plugins/data/server/search/collectors/register.ts @@ -54,7 +54,7 @@ export async function registerUsageCollector( }, }); usageCollection.registerCollector(collector); - } catch (err) { + } catch (err: any) { return; // OpenSearch Dashboards plugin is not enabled (test environment) } } diff --git a/src/plugins/data/server/search/collectors/usage.ts b/src/plugins/data/server/search/collectors/usage.ts index d227dea8057c..2179891b159a 100644 --- a/src/plugins/data/server/search/collectors/usage.ts +++ b/src/plugins/data/server/search/collectors/usage.ts @@ -61,7 +61,7 @@ export function usageProvider( try { const response = await repository.get(SAVED_OBJECT_ID, SAVED_OBJECT_ID); attributes = response.attributes; - } catch (e) { + } catch (e: any) { doesSavedObjectExist = false; attributes = { successCount: 0, @@ -84,7 +84,7 @@ export function usageProvider( } else { await repository.create(SAVED_OBJECT_ID, attributes, { id: SAVED_OBJECT_ID }); } - } catch (e) { + } catch (e: any) { // Version conflict error, swallow } } diff --git a/src/plugins/data/server/search/opensearch_search/opensearch_search_strategy.ts b/src/plugins/data/server/search/opensearch_search/opensearch_search_strategy.ts index ba50740e6baf..fca71dab1633 100644 --- a/src/plugins/data/server/search/opensearch_search/opensearch_search_strategy.ts +++ b/src/plugins/data/server/search/opensearch_search/opensearch_search_strategy.ts @@ -88,7 +88,7 @@ export const opensearchSearchStrategyProvider = ( rawResponse, ...getTotalLoaded(rawResponse._shards), }; - } catch (e) { + } catch (e: any) { if (usage) usage.trackError(); if (dataSource && request.dataSourceId) { diff --git a/src/plugins/data/server/search/routes/msearch.ts b/src/plugins/data/server/search/routes/msearch.ts index 2dc13098aa3c..f01c24324e2f 100644 --- a/src/plugins/data/server/search/routes/msearch.ts +++ b/src/plugins/data/server/search/routes/msearch.ts @@ -79,7 +79,7 @@ export function registerMsearchRoute(router: IRouter, deps: SearchRouteDependenc try { const response = await callMsearch({ body: request.body }); return res.ok(response); - } catch (err) { + } catch (err: any) { return res.customError({ statusCode: err.statusCode || 500, body: { diff --git a/src/plugins/data/server/search/routes/search.ts b/src/plugins/data/server/search/routes/search.ts index 1fa4c00e2463..fbb0ad807655 100644 --- a/src/plugins/data/server/search/routes/search.ts +++ b/src/plugins/data/server/search/routes/search.ts @@ -77,7 +77,7 @@ export function registerSearchRoute( }, }, }); - } catch (err) { + } catch (err: any) { return res.customError({ statusCode: err.statusCode || 500, body: { @@ -113,7 +113,7 @@ export function registerSearchRoute( try { await searchStrategy.cancel(context, id); return res.ok(); - } catch (err) { + } catch (err: any) { return res.customError({ statusCode: err.statusCode, body: { diff --git a/src/plugins/data_source/server/audit/logging_auditor.ts b/src/plugins/data_source/server/audit/logging_auditor.ts index bc1f5bc57dcb..dd102bde941c 100644 --- a/src/plugins/data_source/server/audit/logging_auditor.ts +++ b/src/plugins/data_source/server/audit/logging_auditor.ts @@ -3,13 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { AuditableEvent, Auditor, Logger, OpenSearchDashboardsRequest } from 'src/core/server'; +import { AuditableEvent, Auditor, Logger } from 'src/core/server'; export class LoggingAuditor implements Auditor { - constructor( - private readonly request: OpenSearchDashboardsRequest, - private readonly logger: Logger - ) {} + constructor(private readonly logger: Logger) {} public withAuditScope(name: string) {} diff --git a/src/plugins/data_source/server/client/configure_client.ts b/src/plugins/data_source/server/client/configure_client.ts index c4d1b4eef9f7..01ecba43ec17 100644 --- a/src/plugins/data_source/server/client/configure_client.ts +++ b/src/plugins/data_source/server/client/configure_client.ts @@ -13,7 +13,7 @@ import { } from '../../common/data_sources'; import { DataSourcePluginConfigType } from '../../config'; import { CryptographyServiceSetup } from '../cryptography_service'; -import { createDataSourceError, DataSourceError } from '../lib/error'; +import { createDataSourceError } from '../lib/error'; import { DataSourceClientParams } from '../types'; import { parseClientOptions } from './client_config'; import { OpenSearchClientPoolSetup } from './client_pool'; diff --git a/src/plugins/data_source/server/data_source_service.ts b/src/plugins/data_source/server/data_source_service.ts index 8466bb7e914b..5556da4476e4 100644 --- a/src/plugins/data_source/server/data_source_service.ts +++ b/src/plugins/data_source/server/data_source_service.ts @@ -3,12 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { - Auditor, - LegacyCallAPIOptions, - Logger, - OpenSearchClient, -} from '../../../../src/core/server'; +import { LegacyCallAPIOptions, Logger, OpenSearchClient } from '../../../../src/core/server'; import { DataSourcePluginConfigType } from '../config'; import { configureClient, OpenSearchClientPool } from './client'; import { configureLegacyClient } from './legacy'; diff --git a/src/plugins/data_source/server/legacy/configure_legacy_client.ts b/src/plugins/data_source/server/legacy/configure_legacy_client.ts index 94e6b40a4d2e..e580e8e527ae 100644 --- a/src/plugins/data_source/server/legacy/configure_legacy_client.ts +++ b/src/plugins/data_source/server/legacy/configure_legacy_client.ts @@ -23,7 +23,7 @@ import { CryptographyServiceSetup } from '../cryptography_service'; import { DataSourceClientParams, LegacyClientCallAPIParams } from '../types'; import { OpenSearchClientPoolSetup, getCredential, getDataSource } from '../client'; import { parseClientOptions } from './client_config'; -import { createDataSourceError, DataSourceError } from '../lib/error'; +import { createDataSourceError } from '../lib/error'; export const configureLegacyClient = async ( { dataSourceId, savedObjects, cryptography }: DataSourceClientParams, @@ -136,7 +136,7 @@ const callAPI = async ( } return request.then(resolve, reject); }); - } catch (err) { + } catch (err: any) { if (!options.wrap401Errors || err.statusCode !== 401) { throw err; } diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx index 08ac198c7561..4aa462b20a29 100644 --- a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx @@ -48,7 +48,7 @@ export const CreateDataSourceWizard: React.FunctionComponent datasource.title?.toLowerCase()) ); } - } catch (e) { + } catch (e: any) { handleDisplayToastMessage({ id: 'dataSourcesManagement.createDataSource.existingDatasourceNames', defaultMessage: 'Unable to fetch some resources.', @@ -65,7 +65,7 @@ export const CreateDataSourceWizard: React.FunctionComponent { /* Cancel Changes */ test('should reset form on click cancel changes', async () => { - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { updateInputFieldAndBlur(component, descriptionFieldIdentifier, ''); expect( @@ -168,7 +168,7 @@ describe('Datasource Management: Edit Datasource Form', () => { resolve(); }, 100) ); - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { /* Updated description*/ updateInputFieldAndBlur(component, descriptionFieldIdentifier, 'testDescription'); @@ -191,7 +191,7 @@ describe('Datasource Management: Edit Datasource Form', () => { /* Save Changes */ test('should update the form with Username&Password on click save changes', async () => { - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { updateInputFieldAndBlur(component, descriptionFieldIdentifier, ''); expect( @@ -201,7 +201,7 @@ describe('Datasource Management: Edit Datasource Form', () => { resolve(); }, 100) ); - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { /* Updated description*/ updateInputFieldAndBlur(component, descriptionFieldIdentifier, 'testDescription'); @@ -298,7 +298,7 @@ describe('Datasource Management: Edit Datasource Form', () => { /* Save Changes */ test('should update the form with NoAUth on click save changes', async () => { - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { updateInputFieldAndBlur(component, descriptionFieldIdentifier, ''); expect( @@ -308,7 +308,7 @@ describe('Datasource Management: Edit Datasource Form', () => { resolve(); }, 100) ); - await new Promise((resolve) => + await new Promise((resolve) => setTimeout(() => { /* Updated description*/ updateInputFieldAndBlur(component, descriptionFieldIdentifier, 'testDescription'); diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx index 46c91ad540c8..9b116c19c439 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx @@ -104,7 +104,7 @@ export class EditDataSourceForm extends React.Component datasource.title?.toLowerCase()) ); } - } catch (e) { + } catch (e: any) { setDataSource(defaultDataSource); handleDisplayToastMessage({ id: 'dataSourcesManagement.editDataSource.fetchDataSourceFailMsg', @@ -101,7 +101,7 @@ export const EditDataSource: React.FunctionComponent { try { mockErrorResponseForSavedObjectsCalls(savedObjects.client, 'find'); await getDataSources(savedObjects.client); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); @@ -74,7 +74,7 @@ describe('DataSourceManagement: Utils.ts', () => { try { mockErrorResponseForSavedObjectsCalls(savedObjects.client, 'get'); await getDataSourceById('alpha-test', savedObjects.client); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); @@ -93,7 +93,7 @@ describe('DataSourceManagement: Utils.ts', () => { try { mockErrorResponseForSavedObjectsCalls(savedObjects.client, 'create'); await createSingleDataSource(savedObjects.client, mockDataSourceAttributesWithAuth); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); @@ -117,7 +117,7 @@ describe('DataSourceManagement: Utils.ts', () => { 'ds-1234', mockDataSourceAttributesWithAuth ); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); @@ -133,7 +133,7 @@ describe('DataSourceManagement: Utils.ts', () => { try { mockErrorResponseForSavedObjectsCalls(savedObjects.client, 'delete'); await deleteDataSourceById('ds-1234', savedObjects.client); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); @@ -145,7 +145,7 @@ describe('DataSourceManagement: Utils.ts', () => { mockResponseForSavedObjectsCalls(savedObjects.client, 'delete', {}); await deleteMultipleDataSources(savedObjects.client, getMappedDataSources); expect(true).toBe(true); // This will be executed if multiple delete call is successful. - } catch (e) { + } catch (e: any) { // this block should not execute as the test case name suggests expect(e).toBeFalsy(); } @@ -154,7 +154,7 @@ describe('DataSourceManagement: Utils.ts', () => { try { mockErrorResponseForSavedObjectsCalls(savedObjects.client, 'delete'); await deleteMultipleDataSources(savedObjects.client, getMappedDataSources); - } catch (e) { + } catch (e: any) { expect(e).toBeTruthy(); } }); diff --git a/src/plugins/data_source_management/public/components/utils.ts b/src/plugins/data_source_management/public/components/utils.ts index 51f190be1ba0..561b52202e76 100644 --- a/src/plugins/data_source_management/public/components/utils.ts +++ b/src/plugins/data_source_management/public/components/utils.ts @@ -83,7 +83,7 @@ export const isValidUrl = (endpoint: string) => { try { const url = new URL(endpoint); return Boolean(url) && (url.protocol === 'http:' || url.protocol === 'https:'); - } catch (e) { + } catch (e: any) { return false; } }; diff --git a/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts b/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts index b5ca9fec1c2f..123f5b1e8747 100644 --- a/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts +++ b/src/plugins/discover/public/application/components/doc/use_opensearch_doc_search.ts @@ -98,7 +98,7 @@ export function useOpenSearchDocSearch({ } else { setStatus(OpenSearchRequestState.NotFound); } - } catch (err) { + } catch (err: any) { if (err.savedObjectId) { setStatus(OpenSearchRequestState.NotFoundIndexPattern); } else if (err.status === 404) { diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx index 4a1390cb1955..a06271d6f01d 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx @@ -236,7 +236,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { legend={legend} options={toggleButtons(id)} idSelected={`${id}-${values[id]}`} - onChange={(optionId) => handleValueChange(id, optionId.replace(`${id}-`, ''))} + onChange={(optionId: string) => handleValueChange(id, optionId.replace(`${id}-`, ''))} buttonSize="compressed" isFullWidth data-test-subj={`${id}ButtonGroup`} diff --git a/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.ts b/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.ts index 54f8832fa1fc..f3bb21ac4b08 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.ts +++ b/src/plugins/discover/public/application/components/sidebar/lib/field_calculator.ts @@ -105,7 +105,7 @@ const getFieldValueCounts = (params: FieldValueCountsParams): FieldValueCounts = missing, buckets: counts, }; - } catch (e) { + } catch (e: any) { return { error: e instanceof Error ? e.message : String(e), }; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 933f807f8153..b0dbf03fafcf 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -326,7 +326,7 @@ export class SearchEmbeddable this.searchScope!.hits = resp.hits.hits; this.searchScope!.totalHitCount = resp.hits.total; }); - } catch (error) { + } catch (error: any) { this.updateOutput({ loading: false, error }); } }; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts index 9b8c540713ce..696d3fbc2a60 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts @@ -119,7 +119,7 @@ export class SearchEmbeddableFactory executeTriggerActions, parent ); - } catch (e) { + } catch (e: any) { console.error(e); // eslint-disable-line no-console return new ErrorEmbeddable(e, input, parent); } diff --git a/src/plugins/discover/server/saved_objects/search_migrations.ts b/src/plugins/discover/server/saved_objects/search_migrations.ts index 712ce3e57c96..c7e0fddead6e 100644 --- a/src/plugins/discover/server/saved_objects/search_migrations.ts +++ b/src/plugins/discover/server/saved_objects/search_migrations.ts @@ -46,7 +46,7 @@ const migrateMatchAllQuery: SavedObjectMigrationFn = (doc) => { try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc; } @@ -81,7 +81,7 @@ const migrateIndexPattern: SavedObjectMigrationFn = (doc) => { let searchSource; try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc; } diff --git a/src/plugins/embeddable/public/lib/containers/container.ts b/src/plugins/embeddable/public/lib/containers/container.ts index 96e687398b71..d932f4ea71bc 100644 --- a/src/plugins/embeddable/public/lib/containers/container.ts +++ b/src/plugins/embeddable/public/lib/containers/container.ts @@ -186,7 +186,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(); - resolve(undefined); + resolve((undefined as unknown) as TEmbeddable); } }); }); @@ -311,7 +311,7 @@ export abstract class Container< embeddable = isSavedObjectEmbeddableInput(inputForChild) ? await factory.createFromSavedObject(inputForChild.savedObjectId, inputForChild, this) : await factory.create(inputForChild, this); - } catch (e) { + } catch (e: any) { embeddable = new ErrorEmbeddable(e, { id: panel.explicitInput.id }, this); } diff --git a/src/plugins/embeddable/public/lib/state_transfer/types.ts b/src/plugins/embeddable/public/lib/state_transfer/types.ts index 98e257c80e5f..e9139c8deeb7 100644 --- a/src/plugins/embeddable/public/lib/state_transfer/types.ts +++ b/src/plugins/embeddable/public/lib/state_transfer/types.ts @@ -64,8 +64,8 @@ export function isEmbeddablePackageState(state: unknown): state is EmbeddablePac function ensureFieldOfTypeExists(key: string, obj: unknown, type?: string): boolean { return ( - obj && - key in (obj as { [key: string]: unknown }) && - (!type || typeof (obj as { [key: string]: unknown })[key] === type) + !!obj && + key in (obj as { [key: string]: any }) && + (!type || typeof (obj as { [key: string]: any })[key] === type) ); } diff --git a/src/plugins/embeddable/public/tests/helpers.ts b/src/plugins/embeddable/public/tests/helpers.ts index 889940c396f4..dff11dd5c9e7 100644 --- a/src/plugins/embeddable/public/tests/helpers.ts +++ b/src/plugins/embeddable/public/tests/helpers.ts @@ -45,7 +45,7 @@ export const expectError = (fn: (...args: any) => any): Error => { try { fn(); throw new Error('Expected an error throw.'); - } catch (error) { + } catch (error: any) { if (error.message === 'Expected an error throw.') { throw error; } @@ -58,7 +58,7 @@ export const of = async >( ): Promise<[T | undefined, Error | any]> => { try { return [await promise, undefined]; - } catch (error) { + } catch (error: any) { return [, error]; } }; diff --git a/src/plugins/expressions/common/ast/parse.ts b/src/plugins/expressions/common/ast/parse.ts index 209f34676bb8..ae6554875b0e 100644 --- a/src/plugins/expressions/common/ast/parse.ts +++ b/src/plugins/expressions/common/ast/parse.ts @@ -39,7 +39,7 @@ export function parse( ): S extends 'expression' ? ExpressionAstExpression : ExpressionAstArgument { try { return parseRaw(String(expression), { startRule }); - } catch (e) { + } catch (e: any) { throw new Error(`Unable to parse expression: ${e.message}`); } } diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts index d848013951f4..1b09f091c581 100644 --- a/src/plugins/expressions/common/execution/execution.ts +++ b/src/plugins/expressions/common/execution/execution.ts @@ -258,7 +258,7 @@ export class Execution< if (getType(output) === 'error') return output; input = output; - } catch (rawError) { + } catch (rawError: any) { const timeEnd: number = this.params.debug ? now() : 0; const error = createError(rawError) as ExpressionValueError; error.error.message = `[${fnName}] > ${error.error.message}`; @@ -306,7 +306,7 @@ export class Execution< if (type && type.validate) { try { type.validate(output); - } catch (e) { + } catch (e: any) { throw new Error(`Output of '${fn.name}' is not a valid type '${fn.type}': ${e}`); } } diff --git a/src/plugins/expressions/common/execution/execution_contract.ts b/src/plugins/expressions/common/execution/execution_contract.ts index e95e1b434cf1..a9ac4de23fdf 100644 --- a/src/plugins/expressions/common/execution/execution_contract.ts +++ b/src/plugins/expressions/common/execution/execution_contract.ts @@ -67,7 +67,7 @@ export class ExecutionContract< getData = async () => { try { return await this.execution.result; - } catch (e) { + } catch (e: any) { return { type: 'error', error: { diff --git a/src/plugins/expressions/common/mocks.ts b/src/plugins/expressions/common/mocks.ts index 4fd434de7d5f..da78f2cff620 100644 --- a/src/plugins/expressions/common/mocks.ts +++ b/src/plugins/expressions/common/mocks.ts @@ -43,6 +43,8 @@ export const createMockExecutionContext = dispatchEvent: jest.fn(), onabort: jest.fn(), removeEventListener: jest.fn(), + reason: '', + throwIfAborted: jest.fn(), }, inspectorAdapters: { requests: {} as any, diff --git a/src/plugins/expressions/public/render.test.ts b/src/plugins/expressions/public/render.test.ts index 73ecab2a0061..4b644a81ebd1 100644 --- a/src/plugins/expressions/public/render.test.ts +++ b/src/plugins/expressions/public/render.test.ts @@ -68,7 +68,7 @@ const mockMockErrorRenderFunction = jest.fn( const getHandledError = () => { try { return mockMockErrorRenderFunction.mock.calls[0][1]; - } catch (e) { + } catch (e: any) { return null; } }; @@ -140,7 +140,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/expressions/public/render.ts b/src/plugins/expressions/public/render.ts index 2e3989969dd1..4a746d0b53a0 100644 --- a/src/plugins/expressions/public/render.ts +++ b/src/plugins/expressions/public/render.ts @@ -133,7 +133,7 @@ export class ExpressionRenderHandler { ...this.handlers, uiState, }); - } catch (e) { + } catch (e: any) { return this.handleRenderError(e as Error); } }; diff --git a/src/plugins/home/server/routes/fetch_opensearch_hits_status.ts b/src/plugins/home/server/routes/fetch_opensearch_hits_status.ts index 0bc0da981886..08712c8f3c7d 100644 --- a/src/plugins/home/server/routes/fetch_opensearch_hits_status.ts +++ b/src/plugins/home/server/routes/fetch_opensearch_hits_status.ts @@ -61,7 +61,7 @@ export const registerHitsStatusRoute = (router: IRouter) => { count, }, }); - } catch (e) { + } catch (e: any) { return res.badRequest({ body: e, }); diff --git a/src/plugins/home/server/services/sample_data/lib/load_data.ts b/src/plugins/home/server/services/sample_data/lib/load_data.ts index 4933e1c8e3d8..042070036094 100644 --- a/src/plugins/home/server/services/sample_data/lib/load_data.ts +++ b/src/plugins/home/server/services/sample_data/lib/load_data.ts @@ -48,7 +48,7 @@ export function loadData(path: any, bulkInsert: (docs: any[]) => Promise) if (docs.length > 0) { try { await bulkInsert(docs); - } catch (err) { + } catch (err: any) { reject(err); return; } @@ -71,7 +71,7 @@ export function loadData(path: any, bulkInsert: (docs: any[]) => Promise) let doc; try { doc = JSON.parse(line); - } catch (err) { + } catch (err: any) { closeWithError( new Error( `Unable to parse line as JSON document, line: """${line}""", Error: ${err.message}` @@ -93,7 +93,7 @@ export function loadData(path: any, bulkInsert: (docs: any[]) => Promise) try { await bulkInsert(docstmp); lineStream.resume(); - } catch (err) { + } catch (err: any) { closeWithError(err); } } diff --git a/src/plugins/home/server/services/sample_data/routes/install.ts b/src/plugins/home/server/services/sample_data/routes/install.ts index eec5f0d5bc86..c07978976d35 100644 --- a/src/plugins/home/server/services/sample_data/routes/install.ts +++ b/src/plugins/home/server/services/sample_data/routes/install.ts @@ -127,7 +127,7 @@ export function createInstallRoute( await context.core.opensearch.legacy.client.callAsCurrentUser('indices.delete', { index, }); - } catch (err) { + } catch (err: any) { // ignore delete errors } @@ -143,7 +143,7 @@ export function createInstallRoute( 'indices.create', createIndexParams ); - } catch (err) { + } catch (err: any) { const errMsg = `Unable to create sample data index "${index}", error: ${err.message}`; logger.warn(errMsg); return res.customError({ body: errMsg, statusCode: err.status }); @@ -158,7 +158,7 @@ export function createInstallRoute( logger ); (counts as any)[index] = count; - } catch (err) { + } catch (err: any) { const errMsg = `sample_data install errors while loading data. Error: ${err}`; logger.warn(errMsg); return res.internalError({ body: errMsg }); @@ -171,7 +171,7 @@ export function createInstallRoute( sampleDataset.savedObjects.map(({ version, ...savedObject }) => savedObject), { overwrite: true } ); - } catch (err) { + } catch (err: any) { const errMsg = `bulkCreate failed, error: ${err.message}`; logger.warn(errMsg); return res.internalError({ body: errMsg }); diff --git a/src/plugins/home/server/services/sample_data/routes/list.ts b/src/plugins/home/server/services/sample_data/routes/list.ts index a0665132dd10..6d37b5c31059 100644 --- a/src/plugins/home/server/services/sample_data/routes/list.ts +++ b/src/plugins/home/server/services/sample_data/routes/list.ts @@ -74,7 +74,7 @@ export const createListRoute = (router: IRouter, sampleDatasets: SampleDatasetSc sampleDataset.status = NOT_INSTALLED; return; } - } catch (err) { + } catch (err: any) { sampleDataset.status = UNKNOWN; sampleDataset.statusMsg = err.message; return; @@ -82,7 +82,7 @@ export const createListRoute = (router: IRouter, sampleDatasets: SampleDatasetSc } try { await context.core.savedObjects.client.get('dashboard', sampleDataset.overviewDashboard); - } catch (err) { + } catch (err: any) { if (context.core.savedObjects.client.errors.isNotFoundError(err)) { sampleDataset.status = NOT_INSTALLED; return; diff --git a/src/plugins/home/server/services/sample_data/routes/uninstall.ts b/src/plugins/home/server/services/sample_data/routes/uninstall.ts index e38a2224aae8..9347a0e75815 100644 --- a/src/plugins/home/server/services/sample_data/routes/uninstall.ts +++ b/src/plugins/home/server/services/sample_data/routes/uninstall.ts @@ -73,7 +73,7 @@ export function createUninstallRoute( try { await callAsCurrentUser('indices.delete', { index }); - } catch (err) { + } catch (err: any) { return response.customError({ statusCode: err.status, body: { @@ -89,7 +89,7 @@ export function createUninstallRoute( try { await Promise.all(deletePromises); - } catch (err) { + } catch (err: any) { // ignore 404s since users could have deleted some of the saved objects via the UI if (_.get(err, 'output.statusCode') !== 404) { return response.customError({ diff --git a/src/plugins/home/server/services/sample_data/sample_data_registry.ts b/src/plugins/home/server/services/sample_data/sample_data_registry.ts index d90de532c339..e510ce61dbe7 100644 --- a/src/plugins/home/server/services/sample_data/sample_data_registry.ts +++ b/src/plugins/home/server/services/sample_data/sample_data_registry.ts @@ -173,7 +173,7 @@ export class SampleDataRegistry { } panel.embeddableConfig = embeddableConfig; dashboard.attributes.panelsJSON = JSON.stringify(panels); - } catch (error) { + } catch (error: any) { throw new Error( `Unable to replace panel with embeddable ${oldEmbeddableId}, error: ${error}` ); diff --git a/src/plugins/home/server/services/sample_data/usage/collector.ts b/src/plugins/home/server/services/sample_data/usage/collector.ts index bceb925ab13a..3c126a30bbb9 100644 --- a/src/plugins/home/server/services/sample_data/usage/collector.ts +++ b/src/plugins/home/server/services/sample_data/usage/collector.ts @@ -41,7 +41,7 @@ export async function makeSampleDataUsageCollector( try { const config = await context.config.legacy.globalConfig$.pipe(first()).toPromise(); index = config.opensearchDashboards.index; - } catch (err) { + } catch (err: any) { return; // OpenSearch Dashboards plugin is not enabled (test environment) } const collector = usageCollection.makeUsageCollector({ diff --git a/src/plugins/home/server/services/sample_data/usage/usage.ts b/src/plugins/home/server/services/sample_data/usage/usage.ts index 3f8c3539dbb7..92e3e4753668 100644 --- a/src/plugins/home/server/services/sample_data/usage/usage.ts +++ b/src/plugins/home/server/services/sample_data/usage/usage.ts @@ -55,7 +55,7 @@ export function usage( try { const internalRepository = await internalRepositoryPromise; await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `installCount`); - } catch (err) { + } catch (err: any) { handleIncrementError(err); } }, @@ -63,7 +63,7 @@ export function usage( try { const internalRepository = await internalRepositoryPromise; await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `unInstallCount`); - } catch (err) { + } catch (err: any) { handleIncrementError(err); } }, diff --git a/src/plugins/home/server/services/tutorials/tutorials_registry.ts b/src/plugins/home/server/services/tutorials/tutorials_registry.ts index 39c14060e30a..11bb460b9012 100644 --- a/src/plugins/home/server/services/tutorials/tutorials_registry.ts +++ b/src/plugins/home/server/services/tutorials/tutorials_registry.ts @@ -36,7 +36,6 @@ import { ScopedTutorialContextFactory, } from './lib/tutorials_registry_types'; import { tutorialSchema } from './lib/tutorial_schema'; -import { builtInTutorials } from '../../tutorials/register'; export class TutorialsRegistry { private tutorialProviders: TutorialProvider[] = []; // pre-register all the tutorials we know we want in here diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_data_source/components/header/header.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_data_source/components/header/header.tsx index e5a6fdf60c0e..917b45df5c7e 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_data_source/components/header/header.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_data_source/components/header/header.tsx @@ -85,12 +85,12 @@ export const Header: React.FC = (props: HeaderProps) => { ); }; - const onChangeDefaultChecked = (e) => { + const onChangeDefaultChecked = (e: any) => { setDefaultChecked(e.target.checked); setDataSourceChecked(!e.target.checked); }; - const onChangeDataSourceChecked = (e) => { + const onChangeDataSourceChecked = (e: any) => { setDataSourceChecked(e.target.checked); setDefaultChecked(!e.target.checked); }; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx index 2ef8806191a2..00387525da1b 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/step_time_field.tsx @@ -168,7 +168,7 @@ export class StepTimeField extends Component { try { return await asyncFn; - } catch (errors) { + } catch (errors: any) { this.setState((prevState) => ({ toasts: prevState.toasts.concat([ { @@ -135,7 +135,7 @@ export class CreateIndexPatternWizard extends Component< id: errorMsg.props.id, color: 'warning', iconType: 'alert', - text: errors.body.message, + text: errors?.body?.message, }, ]), })); @@ -202,7 +202,7 @@ export class CreateIndexPatternWizard extends Component< dataSourceRef, ...this.state.indexPatternCreationType.getIndexPatternMappings(), }); - } catch (err) { + } catch (err: any) { if (err instanceof DuplicateIndexPatternError) { const confirmMessage = i18n.translate( 'indexPatternManagement.indexPattern.titleExistsLabel', 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 75eec7e4d820..ec7b13b2d136 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 @@ -47,7 +47,7 @@ describe('ensureMinimumTime', () => { it('resolves in the amount of time provided, at minimum', async () => { 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/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/default/default.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/default/default.tsx index 9d461f5d70e5..6cae7e4e8638 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/default/default.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/default/default.tsx @@ -51,7 +51,7 @@ export const convertSampleInput = ( output: converter(input), }; }); - } catch (e) { + } catch (e: any) { error = i18n.translate('indexPatternManagement.defaultErrorMessage', { defaultMessage: 'An error occurred while trying to use this format configuration: {message}', values: { message: e.message }, diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx index 96862e59ffa5..2b03bf469ad7 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.tsx @@ -30,7 +30,6 @@ import './empty_state.scss'; import React from 'react'; -import { i18n } from '@osd/i18n'; import { FormattedMessage } from '@osd/i18n/react'; import { DocLinksStart, ApplicationStart } from 'opensearch-dashboards/public'; import { diff --git a/src/plugins/index_pattern_management/server/routes/preview_scripted_field.ts b/src/plugins/index_pattern_management/server/routes/preview_scripted_field.ts index 211e19a3dcd3..bbb4c476724d 100644 --- a/src/plugins/index_pattern_management/server/routes/preview_scripted_field.ts +++ b/src/plugins/index_pattern_management/server/routes/preview_scripted_field.ts @@ -69,7 +69,7 @@ export function registerPreviewScriptedFieldRoute(router: IRouter): void { }); return res.ok({ body: response }); - } catch (err) { + } catch (err: any) { return res.customError({ statusCode: err.statusCode || 500, body: { diff --git a/src/plugins/index_pattern_management/server/routes/resolve_index.ts b/src/plugins/index_pattern_management/server/routes/resolve_index.ts index ed463bd54ea7..dd11097b8cea 100644 --- a/src/plugins/index_pattern_management/server/routes/resolve_index.ts +++ b/src/plugins/index_pattern_management/server/routes/resolve_index.ts @@ -71,7 +71,7 @@ export function registerResolveIndexRoute(router: IRouter): void { }`, }); return res.ok({ body: result }); - } catch (err) { + } catch (err: any) { return res.customError({ statusCode: err.statusCode || 500, body: { diff --git a/src/plugins/input_control_vis/public/components/editor/field_select.tsx b/src/plugins/input_control_vis/public/components/editor/field_select.tsx index 6da76c7120a8..5186738aa3c7 100644 --- a/src/plugins/input_control_vis/public/components/editor/field_select.tsx +++ b/src/plugins/input_control_vis/public/components/editor/field_select.tsx @@ -99,7 +99,7 @@ class FieldSelectUi extends Component { let indexPattern: IIndexPattern; try { indexPattern = await this.props.getIndexPattern(indexPatternId); - } catch (err) { + } catch (err: any) { // index pattern no longer exists return; } diff --git a/src/plugins/input_control_vis/public/components/editor/list_control_editor.tsx b/src/plugins/input_control_vis/public/components/editor/list_control_editor.tsx index d5e2ddbe532a..f4a48d4685c1 100644 --- a/src/plugins/input_control_vis/public/components/editor/list_control_editor.tsx +++ b/src/plugins/input_control_vis/public/components/editor/list_control_editor.tsx @@ -129,7 +129,7 @@ export class ListControlEditor extends PureComponent< let indexPattern: IIndexPattern; try { indexPattern = await this.props.getIndexPattern(this.props.controlParams.indexPattern); - } catch (err) { + } catch (err: any) { // index pattern no longer exists return; } diff --git a/src/plugins/input_control_vis/public/control/list_control_factory.ts b/src/plugins/input_control_vis/public/control/list_control_factory.ts index 28d8642efaf3..7e91574b49f3 100644 --- a/src/plugins/input_control_vis/public/control/list_control_factory.ts +++ b/src/plugins/input_control_vis/public/control/list_control_factory.ts @@ -174,7 +174,7 @@ export class ListControl extends Control { let resp; try { resp = await searchSource.fetch({ abortSignal }); - } catch (error) { + } catch (error: any) { // If the fetch was aborted then no need to surface this error in the UI if (error.name === 'AbortError') return; diff --git a/src/plugins/input_control_vis/public/control/range_control_factory.ts b/src/plugins/input_control_vis/public/control/range_control_factory.ts index 191822d106cb..ffe95b288b4a 100644 --- a/src/plugins/input_control_vis/public/control/range_control_factory.ts +++ b/src/plugins/input_control_vis/public/control/range_control_factory.ts @@ -109,7 +109,7 @@ export class RangeControl extends Control { let resp; try { resp = await searchSource.fetch({ abortSignal }); - } catch (error) { + } catch (error: any) { // If the fetch was aborted then no need to surface this error in the UI if (error.name === 'AbortError') return; this.disable( diff --git a/src/plugins/opensearch_dashboards_legacy/public/angular/angular_config.tsx b/src/plugins/opensearch_dashboards_legacy/public/angular/angular_config.tsx index ef01d29e4b14..d259ffc297f1 100644 --- a/src/plugins/opensearch_dashboards_legacy/public/angular/angular_config.tsx +++ b/src/plugins/opensearch_dashboards_legacy/public/angular/angular_config.tsx @@ -277,7 +277,7 @@ const $setupBreadcrumbsAutoClear = (newPlatform: CoreStart, isLocalAngular: bool try { newPlatform.chrome.setBreadcrumbs($injector.invoke(k7BreadcrumbsProvider)); - } catch (error) { + } catch (error: any) { if (isAngularHttpError(error)) { error = formatAngularHttpError(error); } @@ -322,7 +322,7 @@ const $setupBadgeAutoClear = (newPlatform: CoreStart, isLocalAngular: boolean) = try { newPlatform.chrome.setBadge($injector.invoke(badgeProvider)); - } catch (error) { + } catch (error: any) { if (isAngularHttpError(error)) { error = formatAngularHttpError(error); } diff --git a/src/plugins/opensearch_dashboards_legacy/public/angular/subscribe_with_scope.ts b/src/plugins/opensearch_dashboards_legacy/public/angular/subscribe_with_scope.ts index f8cb102379b6..a5413c8ec196 100644 --- a/src/plugins/opensearch_dashboards_legacy/public/angular/subscribe_with_scope.ts +++ b/src/plugins/opensearch_dashboards_legacy/public/angular/subscribe_with_scope.ts @@ -47,7 +47,7 @@ function callInDigest($scope: IScope, fn: () => void, fatalError?: FatalErrorFn) } else { $scope.$apply(() => fn()); } - } catch (error) { + } catch (error: any) { if (fatalError) { fatalError(error); } diff --git a/src/plugins/opensearch_dashboards_react/public/table_list_view/table_list_view.tsx b/src/plugins/opensearch_dashboards_react/public/table_list_view/table_list_view.tsx index 4a55bdc3a605..218d76d81057 100644 --- a/src/plugins/opensearch_dashboards_react/public/table_list_view/table_list_view.tsx +++ b/src/plugins/opensearch_dashboards_react/public/table_list_view/table_list_view.tsx @@ -158,7 +158,7 @@ class TableListView extends React.Component this.props.listingLimit, }); } - } catch (fetchError) { + } catch (fetchError: any) { this.setState({ hasInitialFetchReturned: true, isFetchingItems: false, @@ -190,7 +190,7 @@ class TableListView extends React.Component itemsById[id])); - } catch (error) { + } catch (error: any) { this.props.toastNotifications.addDanger({ title: toMountPoint( 0); - } catch (err) { + } catch (err: any) { logger.warn(`Failed to rollup transactional to daily entries`); logger.warn(err); } @@ -124,7 +124,7 @@ async function getDailyDoc( ): Promise { try { return await savedObjectsClient.get(SAVED_OBJECTS_DAILY_TYPE, id); - } catch (err) { + } catch (err: any) { if (SavedObjectsErrorHelpers.isNotFoundError(err)) { return { attributes: { @@ -206,7 +206,7 @@ export async function rollTotals(logger: Logger, savedObjectsClient?: ISavedObje ({ id }) => savedObjectsClient.delete(SAVED_OBJECTS_DAILY_TYPE, id) // There is no bulkDelete :( ), ]); - } catch (err) { + } catch (err: any) { logger.warn(`Failed to rollup daily entries to totals`); logger.warn(err); } diff --git a/src/plugins/opensearch_dashboards_utils/common/of.test.ts b/src/plugins/opensearch_dashboards_utils/common/of.test.ts index 499f831042e4..66280559d9b0 100644 --- a/src/plugins/opensearch_dashboards_utils/common/of.test.ts +++ b/src/plugins/opensearch_dashboards_utils/common/of.test.ts @@ -32,7 +32,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); @@ -51,7 +51,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/opensearch_dashboards_utils/common/of.ts b/src/plugins/opensearch_dashboards_utils/common/of.ts index bd9291ca4a7a..17c138072e3a 100644 --- a/src/plugins/opensearch_dashboards_utils/common/of.ts +++ b/src/plugins/opensearch_dashboards_utils/common/of.ts @@ -42,7 +42,7 @@ export const of = async ( ): Promise<[T | undefined, E | undefined, boolean]> => { try { return [await promise, undefined, true]; - } catch (error) { + } catch (error: any) { return [undefined, error, false]; } }; diff --git a/src/plugins/opensearch_dashboards_utils/public/state_management/state_hash/state_hash.ts b/src/plugins/opensearch_dashboards_utils/public/state_management/state_hash/state_hash.ts index 178a1d66d2ae..06ac6afb5ebe 100644 --- a/src/plugins/opensearch_dashboards_utils/public/state_management/state_hash/state_hash.ts +++ b/src/plugins/opensearch_dashboards_utils/public/state_management/state_hash/state_hash.ts @@ -83,7 +83,7 @@ export function retrieveState(stateHash: string): State { } try { return JSON.parse(json); - } catch (e) { + } catch (e: any) { return throwUnableToRestoreUrlError(); } } diff --git a/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts b/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts index bb4d81853a30..ec1f588cf625 100644 --- a/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts +++ b/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts @@ -170,7 +170,7 @@ export function createOsdUrlTracker({ let urlWithStates = ''; try { urlWithStates = unhashUrl(urlWithHashes); - } catch (e) { + } catch (e: any) { toastNotifications.addDanger(e.message); } diff --git a/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts b/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts index 51df4fe41ae5..951acc278a1d 100644 --- a/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts +++ b/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts @@ -106,7 +106,7 @@ export const createOsdUrlStateStorage = ( return url.updateAsync((currentUrl) => { try { return setStateToOsdUrl(key, state, { useHash }, currentUrl); - } catch (error) { + } catch (error: any) { if (onSetError) onSetError(error); } }, replace); @@ -116,7 +116,7 @@ export const createOsdUrlStateStorage = ( // otherwise current url will be used to retrieve state from try { return getStateFromOsdUrl(key, url.getPendingUrl()); - } catch (e) { + } catch (e: any) { if (onGetError) onGetError(e); return null; } diff --git a/src/plugins/opensearch_dashboards_utils/public/storage/hashed_item_store/hashed_item_store.ts b/src/plugins/opensearch_dashboards_utils/public/storage/hashed_item_store/hashed_item_store.ts index 2e21d292e372..9186c8d816f2 100644 --- a/src/plugins/opensearch_dashboards_utils/public/storage/hashed_item_store/hashed_item_store.ts +++ b/src/plugins/opensearch_dashboards_utils/public/storage/hashed_item_store/hashed_item_store.ts @@ -177,7 +177,7 @@ export class HashedItemStore implements IStorage { try { this.storage.setItem(hash, item); return true; - } catch (e) { + } catch (e: any) { // If there was an error then we need to make some space for the item. if (this.getIndexedItems().length === 0) { // If there's nothing left to remove, then we've run out of space and we're trying to diff --git a/src/plugins/opensearch_dashboards_utils/public/storage/storage.ts b/src/plugins/opensearch_dashboards_utils/public/storage/storage.ts index f7a02820616a..39951fbc0d8a 100644 --- a/src/plugins/opensearch_dashboards_utils/public/storage/storage.ts +++ b/src/plugins/opensearch_dashboards_utils/public/storage/storage.ts @@ -49,7 +49,7 @@ export class Storage implements IStorageWrapper { try { return JSON.parse(storageItem); - } catch (error) { + } catch (error: any) { return null; } }; @@ -57,7 +57,7 @@ export class Storage implements IStorageWrapper { public set = (key: string, value: any) => { try { return this.store.setItem(key, JSON.stringify(value)); - } catch (e) { + } catch (e: any) { return false; } }; diff --git a/src/plugins/opensearch_ui_shared/public/components/json_editor/json_editor.tsx b/src/plugins/opensearch_ui_shared/public/components/json_editor/json_editor.tsx index 23a4d9812e2b..8eae62a80f63 100644 --- a/src/plugins/opensearch_ui_shared/public/components/json_editor/json_editor.tsx +++ b/src/plugins/opensearch_ui_shared/public/components/json_editor/json_editor.tsx @@ -78,7 +78,7 @@ function JsonEditorComp({ try { JSON.parse(updated); return true; - } catch (e) { + } catch (e: any) { return false; } }, diff --git a/src/plugins/opensearch_ui_shared/public/request/send_request.ts b/src/plugins/opensearch_ui_shared/public/request/send_request.ts index b76730d26737..48e614832eeb 100644 --- a/src/plugins/opensearch_ui_shared/public/request/send_request.ts +++ b/src/plugins/opensearch_ui_shared/public/request/send_request.ts @@ -54,7 +54,7 @@ export const sendRequest = async ( data: response.data ? response.data : response, error: null, }; - } catch (e) { + } catch (e: any) { return { data: null, error: e.response?.data ?? e.body, diff --git a/src/plugins/opensearch_ui_shared/public/request/use_request.test.helpers.tsx b/src/plugins/opensearch_ui_shared/public/request/use_request.test.helpers.tsx index e9e6bffb7b59..cd29ea0e008b 100644 --- a/src/plugins/opensearch_ui_shared/public/request/use_request.test.helpers.tsx +++ b/src/plugins/opensearch_ui_shared/public/request/use_request.test.helpers.tsx @@ -108,7 +108,7 @@ export const createUseRequestHelpers = (): UseRequestHelpers => { setTimeout(() => { try { resolve(sendRequestSpy(path, options)); - } catch (e) { + } catch (e: any) { reject(e); } }, (requestTimings && requestTimings[requestCount++]) || REQUEST_TIME); diff --git a/src/plugins/opensearch_ui_shared/static/validators/string/is_json.ts b/src/plugins/opensearch_ui_shared/static/validators/string/is_json.ts index 01ed890ea50d..bfbf2ec283cd 100644 --- a/src/plugins/opensearch_ui_shared/static/validators/string/is_json.ts +++ b/src/plugins/opensearch_ui_shared/static/validators/string/is_json.ts @@ -35,7 +35,7 @@ export const isJSON = (value: string) => { return false; } return true; - } catch (e) { + } catch (e: any) { return false; } }; diff --git a/src/plugins/region_map/public/services.ts b/src/plugins/region_map/public/services.ts index dd26be3ccd7a..a1b71662cc39 100644 --- a/src/plugins/region_map/public/services.ts +++ b/src/plugins/region_map/public/services.ts @@ -21,7 +21,7 @@ export function getServices(http: CoreStart['http']): Services { }), }); return response; - } catch (e) { + } catch (e: any) { return e; } }, @@ -33,7 +33,7 @@ export function getServices(http: CoreStart['http']): Services { }), }); return response; - } catch (e) { + } catch (e: any) { return e; } }, @@ -45,7 +45,7 @@ export function getServices(http: CoreStart['http']): Services { }), }); return response; - } catch (e) { + } catch (e: any) { return e; } }, diff --git a/src/plugins/saved_objects/public/saved_object/helpers/apply_opensearch_resp.ts b/src/plugins/saved_objects/public/saved_object/helpers/apply_opensearch_resp.ts index 754ac59e445c..ac3a3d0efbcf 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/apply_opensearch_resp.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/apply_opensearch_resp.ts @@ -100,7 +100,7 @@ export async function applyOpenSearchResp( } else { savedObject.searchSourceFields = searchSourceValues; } - } catch (error) { + } catch (error: any) { if ( error.constructor.name === 'SavedObjectNotFound' && error.savedObjectType === 'index-pattern' diff --git a/src/plugins/saved_objects/public/saved_object/helpers/build_saved_object.ts b/src/plugins/saved_objects/public/saved_object/helpers/build_saved_object.ts index 14318a177959..d2b423414c5b 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/build_saved_object.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/build_saved_object.ts @@ -120,7 +120,7 @@ export function buildSavedObject( try { const result = await saveSavedObject(savedObject, config, opts, services); return Promise.resolve(result); - } catch (e) { + } catch (e: any) { return Promise.reject(e); } }; diff --git a/src/plugins/saved_objects/public/saved_object/helpers/create_source.ts b/src/plugins/saved_objects/public/saved_object/helpers/create_source.ts index 579eaaa09f60..e080e8a8f1bc 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/create_source.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/create_source.ts @@ -60,7 +60,7 @@ export async function createSource( const { savedObjectsClient, overlays } = services; try { return await savedObjectsClient.create(opensearchType, source, options); - } catch (err) { + } catch (err: any) { // record exists, confirm overwriting if (_.get(err, 'res.status') === 409) { const confirmMessage = i18n.translate( diff --git a/src/plugins/saved_objects/public/saved_object/helpers/save_saved_object.ts b/src/plugins/saved_objects/public/saved_object/helpers/save_saved_object.ts index 01be4f97591e..34af6c0e021b 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/save_saved_object.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/save_saved_object.ts @@ -129,7 +129,7 @@ export async function saveSavedObject( savedObject.isSaving = false; savedObject.lastSavedTitle = savedObject.title; return savedObject.id; - } catch (err) { + } catch (err: any) { savedObject.isSaving = false; savedObject.id = originalId; if (isErrorNonFatal(err)) { diff --git a/src/plugins/saved_objects/public/saved_object/helpers/save_with_confirmation.ts b/src/plugins/saved_objects/public/saved_object/helpers/save_with_confirmation.ts index 3172c08a0466..8c059d92842d 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/save_with_confirmation.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/save_with_confirmation.ts @@ -65,7 +65,7 @@ export async function saveWithConfirmation( const { savedObjectsClient, overlays } = services; try { return await savedObjectsClient.create(savedObject.getOpenSearchType(), source, options); - } catch (err) { + } catch (err: any) { // record exists, confirm overwriting if (get(err, 'res.status') === 409) { const confirmMessage = i18n.translate( diff --git a/src/plugins/saved_objects/public/saved_object/saved_object.test.ts b/src/plugins/saved_objects/public/saved_object/saved_object.test.ts index 7e10a68c2d1f..bad11c568612 100644 --- a/src/plugins/saved_objects/public/saved_object/saved_object.test.ts +++ b/src/plugins/saved_objects/public/saved_object/saved_object.test.ts @@ -427,7 +427,7 @@ describe('Saved Object', () => { try { savedObject.applyOpenSearchResp(response); expect(true).toBe(false); - } catch (err) { + } catch (err: any) { expect(!!err).toBe(true); } }); @@ -733,7 +733,7 @@ describe('Saved Object', () => { try { savedObject.init!(); expect(false).toBe(true); - } catch (err) { + } catch (err: any) { expect(err).not.toBeNull(); } }); diff --git a/src/plugins/saved_objects_management/public/lib/create_field_list.ts b/src/plugins/saved_objects_management/public/lib/create_field_list.ts index 930bc2cf5a60..f323584de5e2 100644 --- a/src/plugins/saved_objects_management/public/lib/create_field_list.ts +++ b/src/plugins/saved_objects_management/public/lib/create_field_list.ts @@ -79,7 +79,7 @@ const createFields = (key: string, value: any, parents: string[] = []): ObjectFi try { field.value = JSON.stringify(JSON.parse(field.value), undefined, 2); field.type = 'json'; - } catch (err) { + } catch (err: any) { field.type = 'text'; } } else if (isNumber(field.value)) { diff --git a/src/plugins/saved_objects_management/public/lib/import_legacy_file.ts b/src/plugins/saved_objects_management/public/lib/import_legacy_file.ts index b673cde16def..7f1a1d544955 100644 --- a/src/plugins/saved_objects_management/public/lib/import_legacy_file.ts +++ b/src/plugins/saved_objects_management/public/lib/import_legacy_file.ts @@ -35,7 +35,7 @@ export async function importLegacyFile(file: File) { const result = event.target!.result as string; try { resolve(JSON.parse(result)); - } catch (e) { + } catch (e: any) { reject(e); } }; diff --git a/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts index f4ec9f8575ae..757fbf25cd3d 100644 --- a/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts +++ b/src/plugins/saved_objects_management/public/lib/resolve_saved_objects.ts @@ -64,7 +64,7 @@ function addJsonFieldToIndexPattern( if (sourceString) { try { target[fieldName] = JSON.parse(sourceString); - } catch (error) { + } catch (error: any) { throw new Error( i18n.translate('savedObjectsManagement.parsingFieldErrorMessage', { defaultMessage: @@ -110,7 +110,7 @@ async function importIndexPattern( addJsonFieldToIndexPattern(indexPatternSpec, typeMeta, 'typeMeta', title); try { emptyPattern = await indexPatterns.createAndSave(indexPatternSpec, overwriteAll, true); - } catch (err) { + } catch (err: any) { if (err instanceof DuplicateIndexPatternError) { // We can override and we want to prompt for confirmation const isConfirmed = await openConfirm( @@ -304,7 +304,7 @@ export async function resolveSavedObjects( if (importedIndexPatternId) { importedObjectCount++; } - } catch (error) { + } catch (error: any) { failedImports.push({ obj: indexPatternDoc as any, error }); } } @@ -331,7 +331,7 @@ export async function resolveSavedObjects( if (await importDocument(obj, searchDoc, overwriteAll)) { importedObjectCount++; } - } catch (error) { + } catch (error: any) { if (error.constructor.name === 'SavedObjectNotFound') { if (error.savedObjectType === 'index-pattern') { conflictedIndexPatterns.push({ obj, doc: searchDoc }); @@ -351,7 +351,7 @@ export async function resolveSavedObjects( if (await importDocument(obj, otherDoc, overwriteAll)) { importedObjectCount++; } - } catch (error) { + } catch (error: any) { const isIndexPatternNotFound = error.constructor.name === 'SavedObjectNotFound' && error.savedObjectType === 'index-pattern'; diff --git a/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx index a53e61a83d5d..fd7641a175b8 100644 --- a/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx +++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/field.tsx @@ -58,7 +58,7 @@ export class Field extends PureComponent { let invalid = false; try { JSON.parse(targetValue); - } catch (e) { + } catch (e: any) { invalid = true; } onChange(name, { @@ -75,7 +75,7 @@ export class Field extends PureComponent { if (type === 'number') { try { newParsedValue = Number(newParsedValue); - } catch (e) { + } catch (e: any) { invalid = true; } } diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx index b0dd8c269039..3aedf8eac295 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.tsx @@ -197,7 +197,7 @@ export class Flyout extends Component { this.resolveImportErrors(); } }); - } catch (e) { + } catch (e: any) { this.setState({ status: 'error', error: getErrorMessage(e), @@ -253,7 +253,7 @@ export class Flyout extends Component { getConflictResolutions: this.getConflictResolutions, }); this.setState(updatedState); - } catch (e) { + } catch (e: any) { this.setState({ status: 'error', error: getErrorMessage(e), @@ -273,7 +273,7 @@ export class Flyout extends Component { let contents; try { contents = await importLegacyFile(file!); - } catch (e) { + } catch (e: any) { this.setState({ status: 'error', error: i18n.translate( @@ -447,7 +447,7 @@ export class Flyout extends Component { failedImports!.map(({ obj }) => obj) as any[], importMode.overwrite ); - } catch (e) { + } catch (e: any) { this.setState({ status: 'error', error: getErrorMessage(e), diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx index ff42351d83af..31db7e2f2117 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.tsx @@ -94,7 +94,7 @@ export class Relationships extends Component { this.setUrl ); } - } catch (fetchError) { + } catch (fetchError: any) { if (this.mounted) { this.shortUrlCache = undefined; this.setState( diff --git a/src/plugins/share/server/routes/lib/short_url_lookup.ts b/src/plugins/share/server/routes/lib/short_url_lookup.ts index f9ff2dd7ba95..2911df4cd618 100644 --- a/src/plugins/share/server/routes/lib/short_url_lookup.ts +++ b/src/plugins/share/server/routes/lib/short_url_lookup.ts @@ -55,7 +55,7 @@ export function shortUrlLookupProvider({ logger }: { logger: Logger }): ShortUrl accessDate: new Date().valueOf(), accessCount: get(doc, 'attributes.accessCount', 0) + 1, }); - } catch (error) { + } catch (error: any) { logger.warn('Warning: Error updating url metadata'); logger.warn(error); // swallow errors. It isn't critical if there is no update. @@ -80,7 +80,7 @@ export function shortUrlLookupProvider({ logger }: { logger: Logger }): ShortUrl ); return doc.id; - } catch (error) { + } catch (error: any) { if (isConflictError(error)) { return id; } diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts index 2c2b33dea8fe..a3d93012386e 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts @@ -95,7 +95,7 @@ function parseSemver(version: string): semver.SemVer | null { // semver functions both return nulls AND throw exceptions: "it depends!" try { return semver.parse(version); - } catch (err) { + } catch (err: any) { return null; } } diff --git a/src/plugins/telemetry/public/plugin.ts b/src/plugins/telemetry/public/plugin.ts index 4553ec13a443..6c821e016192 100644 --- a/src/plugins/telemetry/public/plugin.ts +++ b/src/plugins/telemetry/public/plugin.ts @@ -240,7 +240,7 @@ export class TelemetryPlugin implements Plugin; return attributes; - } catch (error) { + } catch (error: any) { const errorCode = error[Symbol('SavedObjectsClientErrorCode')]; if (errorCode === 'SavedObjectsClient/notFound') { return null; diff --git a/src/plugins/telemetry/public/services/telemetry_sender.ts b/src/plugins/telemetry/public/services/telemetry_sender.ts index c474235fb6b1..a949b302b856 100644 --- a/src/plugins/telemetry/public/services/telemetry_sender.ts +++ b/src/plugins/telemetry/public/services/telemetry_sender.ts @@ -100,7 +100,7 @@ export class TelemetrySender { */ this.lastReported = `${Date.now()}`; this.saveToBrowser(); - } catch (err) { + } catch (err: any) { // ignore err } finally { this.isSending = false; diff --git a/src/plugins/telemetry/public/services/telemetry_service.ts b/src/plugins/telemetry/public/services/telemetry_service.ts index 489e588adb3a..a719c1569d30 100644 --- a/src/plugins/telemetry/public/services/telemetry_service.ts +++ b/src/plugins/telemetry/public/services/telemetry_service.ts @@ -166,7 +166,7 @@ export class TelemetryService { await this.reportOptInStatus(optInPayload); } this.isOptedIn = optedIn; - } catch (err) { + } catch (err: any) { this.notifications.toasts.addError(err, { title: i18n.translate('telemetry.optInErrorToastTitle', { defaultMessage: 'Error', @@ -186,7 +186,7 @@ export class TelemetryService { try { await this.http.put('/api/telemetry/v2/userHasSeenNotice'); this.userHasSeenOptedInNotice = true; - } catch (error) { + } catch (error: any) { this.notifications.toasts.addError(error, { title: i18n.translate('telemetry.optInNoticeSeenErrorTitle', { defaultMessage: 'Error', @@ -214,7 +214,7 @@ export class TelemetryService { }, body: JSON.stringify(optInPayload), }); - } catch (err) { + } catch (err: any) { // Sending the ping is best-effort. Telemetry tries to send the ping once and discards it immediately if sending fails. // swallow any errors } diff --git a/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts b/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts index a08282a647a8..e2cad8b6013d 100644 --- a/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts +++ b/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts @@ -67,7 +67,7 @@ export function createCollectorFetch({ telemetrySavedObject = await getTelemetrySavedObject( new SavedObjectsClient(internalRepository) ); - } catch (err) { + } catch (err: any) { // no-op } diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts index 7e49c7d32445..45c55951fa94 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.test.ts @@ -90,7 +90,7 @@ describe('telemetry_usage_collector', () => { allFiles.forEach((path) => { try { unlinkSync(path); - } catch (err) { + } catch (err: any) { // ignored } }); diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts index 7347975dbc4a..7535fe63430d 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts @@ -60,7 +60,7 @@ export function isFileReadable(path: string): boolean { // ignore files above the limit const stats = statSync(path); return stats.size <= MAX_FILE_SIZE; - } catch (e) { + } catch (e: any) { return false; } } @@ -81,12 +81,12 @@ export async function readTelemetryFile( const data = safeLoad(yaml.toString()); // don't bother returning empty objects - if (Object.keys(data).length) { + if (Object.keys(data || {}).length) { // ensure { "a.b": "value" } becomes { "a": { "b": "value" } } return ensureDeepObject(data); } } - } catch (e) { + } catch (e: any) { // ignored } diff --git a/src/plugins/telemetry/server/fetcher.ts b/src/plugins/telemetry/server/fetcher.ts index 678398e2d22a..d7f97827b89d 100644 --- a/src/plugins/telemetry/server/fetcher.ts +++ b/src/plugins/telemetry/server/fetcher.ts @@ -119,7 +119,7 @@ export class FetcherTask { try { telemetryConfig = await this.getCurrentConfigs(); - } catch (err) { + } catch (err: any) { this.logger.warn(`Error getting telemetry configs. (${err})`); return; } @@ -137,7 +137,7 @@ export class FetcherTask { throw new Error('Not all collectors are ready.'); } clusters = await this.fetchTelemetry(); - } catch (err) { + } catch (err: any) { this.logger.warn(`Error fetching usage. (${err})`); this.isSending = false; return; @@ -150,7 +150,7 @@ export class FetcherTask { } await this.updateLastReported(); - } catch (err) { + } catch (err: any) { await this.updateReportFailure(telemetryConfig); this.logger.warn(`Error sending telemetry usage data. (${err})`); diff --git a/src/plugins/telemetry/server/plugin.ts b/src/plugins/telemetry/server/plugin.ts index 1aa06f31aa1a..b109c83dd905 100644 --- a/src/plugins/telemetry/server/plugin.ts +++ b/src/plugins/telemetry/server/plugin.ts @@ -182,7 +182,7 @@ export class TelemetryPlugin implements Plugin { diff --git a/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.test.ts b/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.test.ts index af3939fd3717..02b046059142 100644 --- a/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.test.ts +++ b/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.test.ts @@ -60,7 +60,7 @@ describe('getTelemetrySavedObject', () => { let threw = false; try { await callGetTelemetrySavedObject(params); - } catch (err) { + } catch (err: any) { threw = true; expect(err.message).toBe(SavedObjectOtherErrorMessage); } diff --git a/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.ts b/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.ts index 0960b9559166..a39ea55956b8 100644 --- a/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.ts +++ b/src/plugins/telemetry/server/telemetry_repository/get_telemetry_saved_object.ts @@ -41,7 +41,7 @@ export const getTelemetrySavedObject: GetTelemetrySavedObject = async ( try { const { attributes } = await repository.get('telemetry', 'telemetry'); return attributes; - } catch (error) { + } catch (error: any) { if (SavedObjectsErrorHelpers.isNotFoundError(error)) { return null; } diff --git a/src/plugins/telemetry/server/telemetry_repository/update_telemetry_saved_object.ts b/src/plugins/telemetry/server/telemetry_repository/update_telemetry_saved_object.ts index 0c8be116a216..85df92417440 100644 --- a/src/plugins/telemetry/server/telemetry_repository/update_telemetry_saved_object.ts +++ b/src/plugins/telemetry/server/telemetry_repository/update_telemetry_saved_object.ts @@ -37,7 +37,7 @@ export async function updateTelemetrySavedObject( ) { try { return await savedObjectsClient.update('telemetry', 'telemetry', savedObjectAttributes); - } catch (err) { + } catch (err: any) { if (SavedObjectsErrorHelpers.isNotFoundError(err)) { return await savedObjectsClient.create('telemetry', savedObjectAttributes, { id: 'telemetry', diff --git a/src/plugins/telemetry_collection_manager/server/plugin.ts b/src/plugins/telemetry_collection_manager/server/plugin.ts index a946cd03e41d..d8168b700929 100644 --- a/src/plugins/telemetry_collection_manager/server/plugin.ts +++ b/src/plugins/telemetry_collection_manager/server/plugin.ts @@ -188,7 +188,7 @@ export class TelemetryCollectionManagerPlugin } return encryptTelemetry(optInStats, { useProdKey: this.isDistributable }); } - } catch (err) { + } catch (err: any) { this.logger.debug(`Failed to collect any opt in stats with registered collections.`); // swallow error to try next collection; } @@ -245,7 +245,7 @@ export class TelemetryCollectionManagerPlugin useProdKey: this.isDistributable, }); } - } catch (err) { + } catch (err: any) { this.logger.debug( `Failed to collect any usage with registered collection ${collection.title}.` ); diff --git a/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.tsx b/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.tsx index 56b0fd1e7ee0..7ffa8361486e 100644 --- a/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.tsx +++ b/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.tsx @@ -77,7 +77,7 @@ export class OptInExampleFlyout extends React.PureComponent { isLoading: false, hasPrivilegeToRead: true, }); - } catch (err) { + } catch (err: any) { this.setState({ isLoading: false, hasPrivilegeToRead: err.status !== 403, diff --git a/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.tsx b/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.tsx index 5e4ac4f0d5e1..a84548351984 100644 --- a/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.tsx +++ b/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.tsx @@ -71,7 +71,7 @@ export class OptInSecurityExampleFlyout extends React.PureComponent { }) ); resolve(true); - } catch (err) { + } catch (err: any) { this.setState({ processing: false }); reject(err); } diff --git a/src/plugins/timeline/public/panels/timechart/schema.ts b/src/plugins/timeline/public/panels/timechart/schema.ts index d18c5337440d..611dfcdaac1d 100644 --- a/src/plugins/timeline/public/panels/timechart/schema.ts +++ b/src/plugins/timeline/public/panels/timechart/schema.ts @@ -403,7 +403,7 @@ export function timechartFn(dependencies: TimelineVisualizationDependencies) { // legend has been re-created. Apply focus on legend element when previously set if (focusedSeries || focusedSeries === 0) { const $legendLabels = canvasElem.find('div.legend table .legendLabel>span'); - $legendLabels.get(focusedSeries).focus(); + $legendLabels.get(focusedSeries)?.focus(); } } } diff --git a/src/plugins/ui_actions/public/actions/action_internal.ts b/src/plugins/ui_actions/public/actions/action_internal.ts index fb39a01ed698..8c11d951a5c2 100644 --- a/src/plugins/ui_actions/public/actions/action_internal.ts +++ b/src/plugins/ui_actions/public/actions/action_internal.ts @@ -41,14 +41,23 @@ import { ActionType } from '../types'; */ export class ActionInternal implements Action>, Presentable> { - constructor(public readonly definition: A) {} + constructor(definition: A) { + this.definition = definition; + this.id = definition.id; + this.type = definition.type || ''; + this.order = definition.order || 0; + this.MenuItem = definition.MenuItem; + this.ReactMenuItem = this.MenuItem ? uiToReactComponent(this.MenuItem) : undefined; + this.grouping = definition.grouping; + } - public readonly id: string = this.definition.id; - public readonly type: ActionType = this.definition.type || ''; - public readonly order: number = this.definition.order || 0; - public readonly MenuItem? = this.definition.MenuItem; - public readonly ReactMenuItem? = this.MenuItem ? uiToReactComponent(this.MenuItem) : undefined; - public readonly grouping?: PresentableGrouping> = this.definition.grouping; + public readonly definition: A; + public readonly id: string; + public readonly type: ActionType; + public readonly order: number; + public readonly MenuItem?; + public readonly ReactMenuItem?: any; + public readonly grouping?: PresentableGrouping>; public execute(context: Context) { return this.definition.execute(context); diff --git a/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts b/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts index d411f97a2a2e..ec3e87d3820d 100644 --- a/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts +++ b/src/plugins/ui_actions/public/service/ui_actions_execution_service.ts @@ -72,7 +72,7 @@ export class UiActionsExecutionService { try { await action.execute({ ...context, trigger }); this.pendingTasks.delete(task); - } catch (e) { + } catch (e: any) { this.pendingTasks.delete(task); throw new Error(e); } @@ -114,7 +114,7 @@ export class UiActionsExecutionService { trigger, }); defer.resolve(); - } catch (e) { + } catch (e: any) { defer.reject(e); } } diff --git a/src/plugins/usage_collection/server/collector/collector_set.test.ts b/src/plugins/usage_collection/server/collector/collector_set.test.ts index 0e4e56034f02..79ce0116ef20 100644 --- a/src/plugins/usage_collection/server/collector/collector_set.test.ts +++ b/src/plugins/usage_collection/server/collector/collector_set.test.ts @@ -123,7 +123,7 @@ describe('CollectorSet', () => { let result; try { result = await collectors.bulkFetch(mockCallCluster, mockOpenSearchClient); - } catch (err) { + } catch (err: any) { // Do nothing } // This must return an empty object instead of null/undefined diff --git a/src/plugins/usage_collection/server/collector/collector_set.ts b/src/plugins/usage_collection/server/collector/collector_set.ts index 2b3a692f1dfb..003bd3d91aef 100644 --- a/src/plugins/usage_collection/server/collector/collector_set.ts +++ b/src/plugins/usage_collection/server/collector/collector_set.ts @@ -149,7 +149,7 @@ export class CollectorSet { type: collector.type, result: await collector.fetch(callCluster, opensearchClient), // each collector must ensure they handle the response appropriately. }; - } catch (err) { + } catch (err: any) { this.logger.warn(err); this.logger.warn(`Unable to fetch data from ${collector.type} collector`); } diff --git a/src/plugins/usage_collection/server/routes/report_metrics.ts b/src/plugins/usage_collection/server/routes/report_metrics.ts index 75080a6b440d..7cef058fd6b9 100644 --- a/src/plugins/usage_collection/server/routes/report_metrics.ts +++ b/src/plugins/usage_collection/server/routes/report_metrics.ts @@ -55,7 +55,7 @@ export function registerUiMetricRoute( } await storeReport(internalRepository, report); return res.ok({ body: { status: 'ok' } }); - } catch (error) { + } catch (error: any) { return res.ok({ body: { status: 'fail' } }); } } diff --git a/src/plugins/vis_builder/public/application/components/data_tab/field.tsx b/src/plugins/vis_builder/public/application/components/data_tab/field.tsx index 287c6aed621c..963dd8cc8a1c 100644 --- a/src/plugins/vis_builder/public/application/components/data_tab/field.tsx +++ b/src/plugins/vis_builder/public/application/components/data_tab/field.tsx @@ -45,7 +45,7 @@ import './field.scss'; export interface FieldProps { field: IndexPatternField; - getDetails: (field) => FieldDetails; + getDetails: (field: any) => FieldDetails; } // TODO: Add field sections (Available fields, popular fields from src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx) diff --git a/src/plugins/vis_builder/public/application/components/data_tab/field_selector.test.tsx b/src/plugins/vis_builder/public/application/components/data_tab/field_selector.test.tsx index 980cfb50c666..9d739b1682c5 100644 --- a/src/plugins/vis_builder/public/application/components/data_tab/field_selector.test.tsx +++ b/src/plugins/vis_builder/public/application/components/data_tab/field_selector.test.tsx @@ -27,7 +27,7 @@ const mockGetDetailsByField = jest.fn(() => ({ total: 150, })); -const getFields = (name) => { +const getFields = (name: any) => { return new IndexPatternField( { name, diff --git a/src/plugins/vis_builder/public/application/components/data_tab/use/use_prefers_reduced_motion.ts b/src/plugins/vis_builder/public/application/components/data_tab/use/use_prefers_reduced_motion.ts index b88c3bc444d0..a7f0a0330f49 100644 --- a/src/plugins/vis_builder/public/application/components/data_tab/use/use_prefers_reduced_motion.ts +++ b/src/plugins/vis_builder/public/application/components/data_tab/use/use_prefers_reduced_motion.ts @@ -14,7 +14,7 @@ export function usePrefersReducedMotion() { useEffect(() => { const mediaQueryList = window.matchMedia(QUERY); - const listener = (event) => { + const listener = (event: any) => { setPrefersReducedMotion(!event.matches); }; diff --git a/src/plugins/vis_builder/public/application/components/data_tab/utils/field_calculator.ts b/src/plugins/vis_builder/public/application/components/data_tab/utils/field_calculator.ts index bd3cde945d95..151c23f3af7b 100644 --- a/src/plugins/vis_builder/public/application/components/data_tab/utils/field_calculator.ts +++ b/src/plugins/vis_builder/public/application/components/data_tab/utils/field_calculator.ts @@ -81,7 +81,7 @@ const getFieldValueCounts = (params: FieldValueCountsParams): FieldValueCounts = missing, buckets: counts, }; - } catch (e) { + } catch (e: any) { return { error: e instanceof Error ? e.message : String(e), }; diff --git a/src/plugins/vis_builder/public/application/components/searchable_dropdown.tsx b/src/plugins/vis_builder/public/application/components/searchable_dropdown.tsx index 36d926457da3..1c97a7ce90c9 100644 --- a/src/plugins/vis_builder/public/application/components/searchable_dropdown.tsx +++ b/src/plugins/vis_builder/public/application/components/searchable_dropdown.tsx @@ -24,14 +24,14 @@ export interface SearchableDropdownOption { interface SearchableDropdownProps { selected?: SearchableDropdownOption; - onChange: (selection) => void; + onChange: (selection: any) => void; options: SearchableDropdownOption[]; loading: boolean; error?: Error; prepend: string; // not just the first time! onOpen?: () => void; - equality: (A, B) => boolean; + equality: (A: any, B: any) => boolean; } type DisplayError = any; @@ -60,12 +60,12 @@ export const SearchableDropdown = ({ }; const closePopover = () => setIsPopoverOpen(false); - function selectNewOption(newOptions) { + function selectNewOption(newOptions: any) { // alright, the EUI Selectable is pretty ratchet // this is as smarmy as it is because it needs to be // first go through and count all the "checked" options - const selectedCount = newOptions.filter((o) => o.checked === 'on').length; + const selectedCount = newOptions.filter((o: any) => o.checked === 'on').length; // if the count is 0, the user just "unchecked" our selection and we can just do nothing if (selectedCount === 0) { @@ -82,7 +82,7 @@ export const SearchableDropdown = ({ } // finally, we can pick the checked option as the actual selection - const newSelection = newOptions.filter((o) => o.checked === 'on')[0]; + const newSelection = newOptions.filter((o: any) => o.checked === 'on')[0]; setLocalOptions(newOptions); setIsPopoverOpen(false); @@ -98,7 +98,7 @@ export const SearchableDropdown = ({ ); }, [selected, options, equality]); - const listDisplay = (list, search) => + const listDisplay = (list: any, search: any) => loading ? (

diff --git a/src/plugins/vis_builder/public/application/utils/breadcrumbs.ts b/src/plugins/vis_builder/public/application/utils/breadcrumbs.ts index 1f5d15a93382..c1cf48777c9d 100644 --- a/src/plugins/vis_builder/public/application/utils/breadcrumbs.ts +++ b/src/plugins/vis_builder/public/application/utils/breadcrumbs.ts @@ -10,7 +10,7 @@ const defaultEditText = i18n.translate('visBuilder.editor.defaultEditBreadcrumbT defaultMessage: 'Edit', }); -export function getVisualizeLandingBreadcrumbs(navigateToApp) { +export function getVisualizeLandingBreadcrumbs(navigateToApp: any) { return [ { text: i18n.translate('visBuilder.listing.breadcrumb', { @@ -21,7 +21,7 @@ export function getVisualizeLandingBreadcrumbs(navigateToApp) { ]; } -export function getCreateBreadcrumbs(navigateToApp) { +export function getCreateBreadcrumbs(navigateToApp: any) { return [ ...getVisualizeLandingBreadcrumbs(navigateToApp), { @@ -32,7 +32,7 @@ export function getCreateBreadcrumbs(navigateToApp) { ]; } -export function getEditBreadcrumbs(text: string = defaultEditText, navigateToApp) { +export function getEditBreadcrumbs(text: string = defaultEditText, navigateToApp: any) { return [ ...getVisualizeLandingBreadcrumbs(navigateToApp), { diff --git a/src/plugins/vis_builder/public/application/utils/get_top_nav_config.tsx b/src/plugins/vis_builder/public/application/utils/get_top_nav_config.tsx index c88bb13f3cb3..06baadbbbdc7 100644 --- a/src/plugins/vis_builder/public/application/utils/get_top_nav_config.tsx +++ b/src/plugins/vis_builder/public/application/utils/get_top_nav_config.tsx @@ -151,11 +151,11 @@ export const getTopNavConfig = ( }; export const getOnSave = ( - savedVisBuilderVis, - originatingApp, - visualizationIdFromUrl, - dispatch, - services + savedVisBuilderVis: any, + originatingApp: any, + visualizationIdFromUrl: any, + dispatch: any, + services: any ) => { const onSave = async ({ newTitle, diff --git a/src/plugins/vis_builder/public/application/utils/use/use_can_save.ts b/src/plugins/vis_builder/public/application/utils/use/use_can_save.ts index 7da320d266f3..56aeb935e5cb 100644 --- a/src/plugins/vis_builder/public/application/utils/use/use_can_save.ts +++ b/src/plugins/vis_builder/public/application/utils/use/use_can_save.ts @@ -20,7 +20,7 @@ export const useCanSave = () => { }; // TODO: Need to finalize the error messages -const getErrorMsg = (isEmpty, hasNoChange, hasDraftAgg) => { +const getErrorMsg = (isEmpty: any, hasNoChange: any, hasDraftAgg: any) => { const i18nTranslate = (key: string, defaultMessage: string) => i18n.translate(`visBuilder.saveVisualizationTooltip.${key}`, { defaultMessage, diff --git a/src/plugins/vis_builder/public/application/utils/use/use_index_pattern.tsx b/src/plugins/vis_builder/public/application/utils/use/use_index_pattern.tsx index 0ce64a36b2ba..d98f9d424619 100644 --- a/src/plugins/vis_builder/public/application/utils/use/use_index_pattern.tsx +++ b/src/plugins/vis_builder/public/application/utils/use/use_index_pattern.tsx @@ -33,7 +33,7 @@ export const useIndexPatterns = () => { const ids = await data.indexPatterns.getIds(true); const patterns = await Promise.all(ids.map((id) => data.indexPatterns.get(id))); setIndexPatterns(patterns); - } catch (e) { + } catch (e: any) { setError(e as Error); } finally { setLoading(false); diff --git a/src/plugins/vis_builder/public/application/utils/use/use_saved_vis_builder_vis.ts b/src/plugins/vis_builder/public/application/utils/use/use_saved_vis_builder_vis.ts index 6e5d861c5318..a14eb5ce14aa 100644 --- a/src/plugins/vis_builder/public/application/utils/use/use_saved_vis_builder_vis.ts +++ b/src/plugins/vis_builder/public/application/utils/use/use_saved_vis_builder_vis.ts @@ -40,7 +40,7 @@ export const useSavedVisBuilderVis = (visualizationIdFromUrl: string | undefined http: { basePath }, toastNotifications, } = services; - const toastNotification = (message) => { + const toastNotification = (message: string) => { toastNotifications.addDanger({ title: i18n.translate('visualize.createVisualization.failedToLoadErrorMessage', { defaultMessage: 'Failed to load the visualization', @@ -86,7 +86,7 @@ export const useSavedVisBuilderVis = (visualizationIdFromUrl: string | undefined setSavedVisState(savedVisBuilderVis); dispatch(setEditorState({ state: 'clean' })); - } catch (error) { + } catch (error: any) { const managementRedirectTarget = { [PLUGIN_ID]: { app: 'management', @@ -107,7 +107,7 @@ export const useSavedVisBuilderVis = (visualizationIdFromUrl: string | undefined if (error instanceof InvalidJSONProperty) { toastNotification(error.message); } - } catch (e) { + } catch (e: any) { const message = e instanceof Error ? e.message : ''; toastNotification(message); history.replace(EDIT_PATH); diff --git a/src/plugins/vis_builder/public/application/utils/vis_builder_state_validation.ts b/src/plugins/vis_builder/public/application/utils/vis_builder_state_validation.ts index 9a601e82594d..086d077bdb3e 100644 --- a/src/plugins/vis_builder/public/application/utils/vis_builder_state_validation.ts +++ b/src/plugins/vis_builder/public/application/utils/vis_builder_state_validation.ts @@ -9,7 +9,7 @@ import visBuilderStateSchema from './schema.json'; const ajv = new Ajv(); const validateState = ajv.compile(visBuilderStateSchema); -export const validateVisBuilderState = (visBuilderState) => { +export const validateVisBuilderState = (visBuilderState: any) => { const isVisBuilderStateValid = validateState(visBuilderState); return { diff --git a/src/plugins/vis_builder/public/embeddable/vis_builder_embeddable_factory.tsx b/src/plugins/vis_builder/public/embeddable/vis_builder_embeddable_factory.tsx index 7c204ac883c3..8972bee1d09c 100644 --- a/src/plugins/vis_builder/public/embeddable/vis_builder_embeddable_factory.tsx +++ b/src/plugins/vis_builder/public/embeddable/vis_builder_embeddable_factory.tsx @@ -104,7 +104,7 @@ export class VisBuilderEmbeddableFactoryDefinition parent, } ); - } catch (e) { + } catch (e: any) { console.error(e); // eslint-disable-line no-console return new ErrorEmbeddable(e as Error, input, parent); } diff --git a/src/plugins/vis_builder/public/plugin.ts b/src/plugins/vis_builder/public/plugin.ts index 8e90a04784cd..1f9de6318483 100644 --- a/src/plugins/vis_builder/public/plugin.ts +++ b/src/plugins/vis_builder/public/plugin.ts @@ -132,14 +132,14 @@ export class VisBuilderPlugin visualizations: { docTypes: [VISBUILDER_SAVED_OBJECT], toListItem: ({ id, attributes, updated_at: updatedAt }) => ({ - description: attributes?.description, + description: attributes?.description!, editApp: PLUGIN_ID, editUrl: `${EDIT_PATH}/${encodeURIComponent(id)}`, icon: visBuilderIcon, id, savedObjectType: VISBUILDER_SAVED_OBJECT, stage: 'experimental', - title: attributes?.title, + title: attributes?.title!, typeTitle: VIS_BUILDER_CHART_TYPE, updated_at: updatedAt, }), diff --git a/src/plugins/vis_builder/public/saved_visualizations/transforms.test.ts b/src/plugins/vis_builder/public/saved_visualizations/transforms.test.ts index 3fb5b7ff7bda..b510d7130e48 100644 --- a/src/plugins/vis_builder/public/saved_visualizations/transforms.test.ts +++ b/src/plugins/vis_builder/public/saved_visualizations/transforms.test.ts @@ -14,8 +14,8 @@ const getConfig = (cfg: any) => cfg; describe('transforms', () => { describe('saveStateToSavedObject', () => { - let TEST_INDEX_PATTERN_ID; - let savedObject; + let TEST_INDEX_PATTERN_ID: string; + let savedObject: VisBuilderVisSavedObject; let rootState: RootState; let indexPattern: IndexPattern; diff --git a/src/plugins/vis_builder/public/visualizations/table/components/table_viz_options.tsx b/src/plugins/vis_builder/public/visualizations/table/components/table_viz_options.tsx index 8c934fff8dac..a77a0811e609 100644 --- a/src/plugins/vis_builder/public/visualizations/table/components/table_viz_options.tsx +++ b/src/plugins/vis_builder/public/visualizations/table/components/table_viz_options.tsx @@ -3,14 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { get } from 'lodash'; -import React, { useCallback, useEffect, useMemo } from 'react'; +import React, { useCallback } from 'react'; import { i18n } from '@osd/i18n'; import { FormattedMessage } from '@osd/i18n/react'; import produce from 'immer'; import { Draft } from 'immer'; import { EuiIconTip } from '@elastic/eui'; -import { search } from '../../../../../data/public'; import { NumberInputOption, SwitchOption } from '../../../../../charts/public'; import { useTypedDispatch, diff --git a/src/plugins/vis_default_editor/public/components/agg.tsx b/src/plugins/vis_default_editor/public/components/agg.tsx index e4d94a87ab03..15f38e615548 100644 --- a/src/plugins/vis_default_editor/public/components/agg.tsx +++ b/src/plugins/vis_default_editor/public/components/agg.tsx @@ -296,7 +296,7 @@ function DefaultEditorAgg({ {SchemaComponent && ( diff --git a/src/plugins/vis_default_editor/public/components/agg_group.test.tsx b/src/plugins/vis_default_editor/public/components/agg_group.test.tsx index 75d3a00d36a4..fad43f26f25c 100644 --- a/src/plugins/vis_default_editor/public/components/agg_group.test.tsx +++ b/src/plugins/vis_default_editor/public/components/agg_group.test.tsx @@ -161,8 +161,8 @@ describe('DefaultEditorAgg component', () => { }); expect(reorderAggs).toHaveBeenCalledWith( - defaultProps.state.data.aggs!.aggs[0], - defaultProps.state.data.aggs!.aggs[1] + defaultProps.state.data?.aggs!.aggs[0], + defaultProps.state.data?.aggs!.aggs[1] ); }); diff --git a/src/plugins/vis_default_editor/public/components/agg_group.tsx b/src/plugins/vis_default_editor/public/components/agg_group.tsx index adcb58960de0..16056d91101e 100644 --- a/src/plugins/vis_default_editor/public/components/agg_group.tsx +++ b/src/plugins/vis_default_editor/public/components/agg_group.tsx @@ -86,10 +86,10 @@ function DefaultEditorAggGroup({ const schemaNames = schemas.map((s) => s.name); const group: IAggConfig[] = useMemo( () => - state.data.aggs!.aggs.filter( + state.data?.aggs!.aggs.filter( (agg: IAggConfig) => agg.schema && schemaNames.includes(agg.schema) ) || [], - [state.data.aggs, schemaNames] + [state.data?.aggs, schemaNames] ); const stats = { diff --git a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts index a16071f51c08..c95d36befe68 100644 --- a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts +++ b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts @@ -192,7 +192,7 @@ function buildAggDescription(agg: IAggConfig) { if (agg.type && agg.type.makeLabel) { try { description = agg.type.makeLabel(agg); - } catch (e) { + } catch (e: any) { // Date Histogram's `makeLabel` implementation invokes 'write' method for each param, including interval's 'write', // which throws an error when interval is undefined. } diff --git a/src/plugins/vis_default_editor/public/components/controls/components/input_list.tsx b/src/plugins/vis_default_editor/public/components/controls/components/input_list.tsx index 32b545c6dfba..d8514a91a044 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/input_list.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/components/input_list.tsx @@ -97,7 +97,7 @@ const validateValue = ( result.model = new InputObject(inputValue).toString(); result.isInvalid = false; return result; - } catch (e) { + } catch (e: any) { result.isInvalid = true; return result; } diff --git a/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts b/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts index ddb62ab5b5cc..2d8be493fab6 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts +++ b/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts @@ -48,7 +48,7 @@ function parse(value: string) { function getRange(range?: string): NumberListRange { try { return range ? parseRange(range) : defaultRange; - } catch (e) { + } catch (e: any) { throw new TypeError('Unable to parse range: ' + e.message); } } diff --git a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx index 1dbce17da3ed..a1cad3e5580e 100644 --- a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx @@ -31,7 +31,6 @@ import React from 'react'; import { AggParamEditorProps } from '../agg_param_props'; import { IAggConfig } from 'src/plugins/data/public'; -import { mount } from 'enzyme'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { PercentilesEditor } from './percentiles'; import { EditorVisState } from '../sidebar/state/reducers'; diff --git a/src/plugins/vis_default_editor/public/components/controls/time_interval.tsx b/src/plugins/vis_default_editor/public/components/controls/time_interval.tsx index 053feda1bcbb..1ee05c76ea76 100644 --- a/src/plugins/vis_default_editor/public/components/controls/time_interval.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/time_interval.tsx @@ -49,7 +49,7 @@ function isValidCalendarInterval(interval: string) { try { parseOpenSearchInterval(interval); return { isValidCalendarValue: true }; - } catch (e) { + } catch (e: any) { if (e instanceof InvalidOpenSearchCalendarIntervalError) { return { isValidCalendarValue: false, error: e.message }; } diff --git a/src/plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts b/src/plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts index 283b9be49494..755747e8d99d 100644 --- a/src/plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts +++ b/src/plugins/vis_default_editor/public/components/controls/utils/agg_utils.ts @@ -122,7 +122,7 @@ function useValidation(setValidity: (isValid: boolean) => void, isValid: boolean function safeMakeLabel(agg: IAggConfig): string { try { return agg.makeLabel(); - } catch (e) { + } catch (e: any) { return i18n.translate('visDefaultEditor.controls.aggNotValidLabel', { defaultMessage: '- agg not valid -', }); diff --git a/src/plugins/vis_type_table_new/public/components/table_vis_grid_columns.tsx b/src/plugins/vis_type_table_new/public/components/table_vis_grid_columns.tsx index ba204ea6ae33..60c15fdc3fcf 100644 --- a/src/plugins/vis_type_table_new/public/components/table_vis_grid_columns.tsx +++ b/src/plugins/vis_type_table_new/public/components/table_vis_grid_columns.tsx @@ -3,9 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React from 'react'; import { i18n } from '@osd/i18n'; -import { EuiDataGridColumn, EuiDataGridColumnCellActionProps } from '@elastic/eui'; +import { EuiDataGridColumn } from '@elastic/eui'; import { IInterpreterRenderHandlers } from 'src/plugins/expressions'; import { OpenSearchDashboardsDatatableRow } from 'src/plugins/expressions'; import { Table } from '../table_vis_response_handler'; @@ -18,26 +17,26 @@ export const getDataGridColumns = ( event: IInterpreterRenderHandlers['event'], columnsWidth: ColumnWidth[] ) => { - const filterBucket = (rowIndex: number, columnIndex: number, negate: boolean) => { - const foramttedColumnId = cols[columnIndex].id; - const rawColumnIndex = table.columns.findIndex((col) => col.id === foramttedColumnId); - event({ - name: 'filterBucket', - data: { - data: [ - { - table: { - columns: table.columns, - rows, - }, - row: rowIndex, - column: rawColumnIndex, - }, - ], - negate, - }, - }); - }; + // const filterBucket = (rowIndex: number, columnIndex: number, negate: boolean) => { + // const foramttedColumnId = cols[columnIndex].id; + // const rawColumnIndex = table.columns.findIndex((col) => col.id === foramttedColumnId); + // event({ + // name: 'filterBucket', + // data: { + // data: [ + // { + // table: { + // columns: table.columns, + // rows, + // }, + // row: rowIndex, + // column: rawColumnIndex, + // }, + // ], + // negate, + // }, + // }); + // }; return cols.map((col, colIndex) => { // const cellActions = col.filterable diff --git a/src/plugins/vis_type_timeline/public/components/timeline_expression_input_helpers.ts b/src/plugins/vis_type_timeline/public/components/timeline_expression_input_helpers.ts index c4c5b5a03d94..2ab31592e354 100644 --- a/src/plugins/vis_type_timeline/public/components/timeline_expression_input_helpers.ts +++ b/src/plugins/vis_type_timeline/public/components/timeline_expression_input_helpers.ts @@ -159,7 +159,7 @@ export async function suggest( functionList, argValueSuggestions ); - } catch (err) { + } catch (err: any) { let message: any; try { // The grammar will throw an error containing a message if the expression is formatted @@ -167,7 +167,7 @@ export async function suggest( // correctly the grammar will just throw a regular PEG SyntaxError, and this JSON.parse // attempt will throw an error. message = JSON.parse(err.message); - } catch (e) { + } catch (e: any) { // The expression isn't correctly formatted, so JSON.parse threw an error. return; } diff --git a/src/plugins/vis_type_timeline/public/components/timeline_vis_component.tsx b/src/plugins/vis_type_timeline/public/components/timeline_vis_component.tsx index 693dafdfe9ae..7c256c900b32 100644 --- a/src/plugins/vis_type_timeline/public/components/timeline_vis_component.tsx +++ b/src/plugins/vis_type_timeline/public/components/timeline_vis_component.tsx @@ -197,7 +197,7 @@ function TimelineVisComponent({ // legend has been re-created. Apply focus on legend element when previously set if (focusedSeries || focusedSeries === 0) { - canvasNode.find('div.legend table .legendLabel>span').get(focusedSeries).focus(); + canvasNode.find('div.legend table .legendLabel>span').get(focusedSeries)?.focus(); } } }, diff --git a/src/plugins/vis_type_timeline/public/helpers/timeline_request_handler.ts b/src/plugins/vis_type_timeline/public/helpers/timeline_request_handler.ts index 467fef727f29..40152b030b81 100644 --- a/src/plugins/vis_type_timeline/public/helpers/timeline_request_handler.ts +++ b/src/plugins/vis_type_timeline/public/helpers/timeline_request_handler.ts @@ -127,7 +127,7 @@ export function getTimelineRequestHandler({ }, }), }); - } catch (e) { + } catch (e: any) { if (e && e.body) { const err = new Error( `${i18n.translate('timeline.requestHandlerErrorTitle', { diff --git a/src/plugins/vis_type_timeline/server/routes/run.ts b/src/plugins/vis_type_timeline/server/routes/run.ts index ab6a993b4bb5..0d7edb179181 100644 --- a/src/plugins/vis_type_timeline/server/routes/run.ts +++ b/src/plugins/vis_type_timeline/server/routes/run.ts @@ -114,7 +114,7 @@ export function runRoute( stats: chainRunner.getStats(), }, }); - } catch (err) { + } catch (err: any) { logger.error(`${err.toString()}: ${err.stack}`); // TODO Maybe we should just replace everywhere we throw with Boom? Probably. if (err.isBoom) { diff --git a/src/plugins/vis_type_timeseries/server/routes/fields.ts b/src/plugins/vis_type_timeseries/server/routes/fields.ts index bff34ee159f5..16dcb1885d9e 100644 --- a/src/plugins/vis_type_timeseries/server/routes/fields.ts +++ b/src/plugins/vis_type_timeseries/server/routes/fields.ts @@ -44,7 +44,7 @@ export const fieldsRoutes = (framework: Framework) => { async (context, req, res) => { try { return res.ok({ body: await getFields(context, req, framework, req.query.index) }); - } catch (err) { + } catch (err: any) { if (isBoom(err) && err.output.statusCode === 401) { return res.customError({ body: err.output.payload, diff --git a/src/plugins/vis_type_timeseries/server/routes/vis.ts b/src/plugins/vis_type_timeseries/server/routes/vis.ts index 4dcf079c5aab..ce0dcd1b11e9 100644 --- a/src/plugins/vis_type_timeseries/server/routes/vis.ts +++ b/src/plugins/vis_type_timeseries/server/routes/vis.ts @@ -52,7 +52,7 @@ export const visDataRoutes = ( async (requestContext, request, response) => { try { visPayloadSchema.validate(request.body); - } catch (error) { + } catch (error: any) { logFailedValidation(); const savedObjectId = (typeof request.body === 'object' && (request.body as any).savedObjectId) || @@ -69,7 +69,7 @@ export const visDataRoutes = ( framework ); return response.ok({ body: results }); - } catch (error) { + } catch (error: any) { return response.internalError({ body: error.message, }); diff --git a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts index b59a8e62a641..aac1f3daf6e8 100644 --- a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts +++ b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts @@ -76,7 +76,7 @@ export class ValidationTelemetryService implements Plugin, columns: string[]) => { try { const cell = item[column]; row[column] = typeof cell === 'object' ? JSON.stringify(cell) : `${cell}`; - } catch (e) { + } catch (e: any) { row[column] = nonSerializableFieldLabel; } return row; diff --git a/src/plugins/vis_type_vega/public/vega_type.ts b/src/plugins/vis_type_vega/public/vega_type.ts index 03fc05fdee89..e6c89b76e060 100644 --- a/src/plugins/vis_type_vega/public/vega_type.ts +++ b/src/plugins/vis_type_vega/public/vega_type.ts @@ -81,7 +81,7 @@ export const createVegaTypeDefinition = ( const spec = parse(visParams.spec, { legacyRoot: false, keepWsc: true }); return extractIndexPatternsFromSpec(spec as VegaSpec); - } catch (e) { + } catch (e: any) { // spec is invalid } return []; diff --git a/src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.ts b/src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.ts index c9ba07c09289..7df574500bd1 100644 --- a/src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.ts +++ b/src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.ts @@ -67,7 +67,7 @@ const getDefaultVegaVisualizations = (home: UsageCollectorDependencies['home']) titles.push(visState.title); } } - } catch (e) { + } catch (e: any) { // Let it go, visState is invalid and we'll don't need to handle it } }) @@ -127,7 +127,7 @@ const getStats = async ( telemetry.vega_use_map_total++; } } - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll don't need to handle it } diff --git a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts index 03666a199dca..2c296105da67 100644 --- a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts +++ b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts @@ -103,7 +103,7 @@ export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDe savedVisualizationsLoader, parent ); - } catch (e) { + } catch (e: any) { console.error(e); // eslint-disable-line no-console return new ErrorEmbeddable(e, input, parent); } diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx index eb9b6dfef529..6aa3e0482d98 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx @@ -168,7 +168,7 @@ export class VisualizeEmbeddableFactory await this.getAttributeService(), parent ); - } catch (e) { + } catch (e: any) { console.error(e); // eslint-disable-line no-console return new ErrorEmbeddable(e, input, parent); } @@ -233,7 +233,7 @@ export class VisualizeEmbeddableFactory ); } return { id }; - } catch (error) { + } catch (error: any) { throw error; } } diff --git a/src/plugins/visualizations/public/saved_visualizations/saved_visualizations.ts b/src/plugins/visualizations/public/saved_visualizations/saved_visualizations.ts index 85296e985a56..acd0db22321d 100644 --- a/src/plugins/visualizations/public/saved_visualizations/saved_visualizations.ts +++ b/src/plugins/visualizations/public/saved_visualizations/saved_visualizations.ts @@ -56,7 +56,7 @@ export function createSavedVisLoader( if (source.visState) { try { typeName = JSON.parse(String(source.visState)).type; - } catch (e) { + } catch (e: any) { /* missing typename handled below */ } } diff --git a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts index 4aa15ecf68d1..fc10231b2e45 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts @@ -40,7 +40,7 @@ const migrateIndexPattern: SavedObjectMigrationFn = (doc) => { let searchSource; try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc; } @@ -82,7 +82,7 @@ const migratePercentileRankAggregation: SavedObjectMigrationFn = (doc) if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.type === 'metrics') { @@ -118,7 +118,7 @@ const migrateFilterRatioQuery: SavedObjectMigrationFn = (doc) => { if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.type === 'metrics') { @@ -157,7 +157,7 @@ const migrateOperatorKeyTypo: SavedObjectMigrationFn = (doc) => { if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.type === 'metrics') { @@ -193,7 +193,7 @@ const migrateSplitByChartRow: SavedObjectMigrationFn = (doc) => { if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } @@ -233,7 +233,7 @@ const migrateDateHistogramAggregation: SavedObjectMigrationFn = (doc) if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } @@ -274,7 +274,7 @@ const removeDateHistogramTimeZones: SavedObjectMigrationFn = (doc) => let visState; try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.aggs) { @@ -319,7 +319,7 @@ const migrateGaugeVerticalSplitToAlignment: SavedObjectMigrationFn = ( }, }; } - } catch (e) { + } catch (e: any) { logger.log.warn(`Exception @ migrateGaugeVerticalSplitToAlignment! ${e}`); logger.log.warn(`Exception @ migrateGaugeVerticalSplitToAlignment! Payload: ${visStateJSON}`); } @@ -344,7 +344,7 @@ const transformFilterStringToQueryObject: SavedObjectMigrationFn = (do let visState; try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // let it go, the data is invalid and we'll leave it as is } if (visState) { @@ -428,7 +428,7 @@ const transformSplitFiltersStringToQueryObject: SavedObjectMigrationFn let visState; try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // let it go, the data is invalid and we'll leave it as is } if (visState) { @@ -489,7 +489,7 @@ const migrateFiltersAggQuery: SavedObjectMigrationFn = (doc) => { }, }; } - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } } @@ -535,7 +535,7 @@ const replaceMovAvgToMovFn: SavedObjectMigrationFn = (doc, logger) => }, }; } - } catch (e) { + } catch (e: any) { logger.log.warn(`Exception @ replaceMovAvgToMovFn! ${e}`); logger.log.warn(`Exception @ replaceMovAvgToMovFn! Payload: ${visStateJSON}`); } @@ -570,7 +570,7 @@ const migrateFiltersAggQueryStringQueries: SavedObjectMigrationFn = (d }, }; } - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } } @@ -606,7 +606,7 @@ const migrateControls: SavedObjectMigrationFn = (doc) => { let visState; try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState) { @@ -661,7 +661,7 @@ const migrateTableSplits: SavedObjectMigrationFn = (doc) => { newDoc.attributes.visState = JSON.stringify(visState); return newDoc; - } catch (e) { + } catch (e: any) { throw new Error(`Failure attempting to migrate saved object '${doc.attributes.title}' - ${e}`); } }; @@ -680,7 +680,7 @@ const migrateMatchAllQuery: SavedObjectMigrationFn = (doc) => { try { searchSource = JSON.parse(searchSourceJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is return doc; } @@ -714,7 +714,7 @@ const migrateTsvbDefaultColorPalettes: SavedObjectMigrationFn = (doc) if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.type === 'metrics') { @@ -749,7 +749,7 @@ const removeTSVBSearchSource: SavedObjectMigrationFn = (doc) => { if (visStateJSON) { try { visState = JSON.parse(visStateJSON); - } catch (e) { + } catch (e: any) { // Let it go, the data is invalid and we'll leave it as is } if (visState && visState.type === 'metrics' && searchSourceJSON !== '{}') { diff --git a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx index 562f96b872ba..fedfa730e20f 100644 --- a/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx +++ b/src/plugins/visualize/public/application/utils/get_top_nav_config.tsx @@ -157,7 +157,7 @@ export const getTopNavConfig = ( } return { id }; - } catch (error) { + } catch (error: any) { // eslint-disable-next-line console.error(error); toastNotifications.addDanger({ diff --git a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts index c80b2b1afd5d..48f69768d3cb 100644 --- a/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts +++ b/src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.ts @@ -129,7 +129,7 @@ export const useSavedVisInstance = ( savedVisInstance, visEditorController, }); - } catch (error) { + } catch (error: any) { const managementRedirectTarget = { app: 'management', path: `opensearch-dashboards/objects/savedVisualizations/${visualizationIdFromUrl}`, @@ -151,7 +151,7 @@ export const useSavedVisInstance = ( setActiveUrl(VisualizeConstants.LANDING_PAGE_PATH); }, })(error); - } catch (e) { + } catch (e: any) { toastNotifications.addWarning({ title: i18n.translate('visualize.createVisualization.failedToLoadErrorMessage', { defaultMessage: 'Failed to load the visualization', 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 e344d94fb4d0..111a685b615f 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 @@ -210,7 +210,7 @@ describe('useVisualizeAppState', () => { renderHook(() => useVisualizeAppState(mockServices, eventEmitter, savedVisInstance)); - await new Promise((res) => { + await new Promise((res) => { setTimeout(() => res()); }); diff --git a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts index 1fc094ef65d7..9d36dd12b08d 100644 --- a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts +++ b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts @@ -44,7 +44,7 @@ export default function optInTest({ getService }: FtrProviderContext) { index: '.kibana', id: 'telemetry:telemetry', } as DeleteDocumentParams); - } catch (err) { + } catch (err: any) { if (err.statusCode !== 404) { throw err; } diff --git a/test/common/services/retry/retry_for_success.ts b/test/common/services/retry/retry_for_success.ts index 2b0560fadfd2..43d39ec3ed65 100644 --- a/test/common/services/retry/retry_for_success.ts +++ b/test/common/services/retry/retry_for_success.ts @@ -48,7 +48,7 @@ async function runAttempt(block: () => Promise): Promise<{ result: T } | { return { result: await block(), }; - } catch (error) { + } catch (error: any) { return { // we rely on error being truthy and throwing falsy values is *allowed* // so we cast falsy values to errors diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 1a303dab14dc..9c181df05381 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -407,7 +407,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo if (toastShown) { try { await this.closeToast(); - } catch (err) { + } catch (err: any) { // ignore errors, toast clear themselves after timeout } } @@ -420,7 +420,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo await toastElement.moveMouseTo(); const closeBtn = await toastElement.findByCssSelector('.euiToast__closeButton'); await closeBtn.click(); - } catch (err) { + } catch (err: any) { // ignore errors, toast clear themselves after timeout } } diff --git a/test/functional/page_objects/dashboard_page.ts b/test/functional/page_objects/dashboard_page.ts index 40e177790695..414c45a75855 100644 --- a/test/functional/page_objects/dashboard_page.ts +++ b/test/functional/page_objects/dashboard_page.ts @@ -543,7 +543,7 @@ export function DashboardPageProvider({ getService, getPageObjects }: FtrProvide 'embeddablePanelNotification-ACTION_PANEL_NOTIFICATIONS' ); return Number.parseInt(await count.getVisibleText(), 10); - } catch (e) { + } catch (e: any) { // if not found then this is 0 (we don't show badge with 0) return 0; } diff --git a/test/functional/page_objects/login_page.ts b/test/functional/page_objects/login_page.ts index 0e740d479761..504825ceffa0 100644 --- a/test/functional/page_objects/login_page.ts +++ b/test/functional/page_objects/login_page.ts @@ -51,7 +51,7 @@ export function LoginPageProvider({ getService }: FtrProviderContext) { await find.setValue('input[type="password"]', pwd); await find.clickByCssSelector('.auth0-label-submit'); await find.byCssSelector('[data-test-subj="opensearchDashboardsChrome"]', 60000); // 60 sec waiting - } catch (err) { + } catch (err: any) { log.debug(`${err} \nFailed to find Auth0 login page, trying the Auth0 last login page`); await find.clickByCssSelector('.auth0-lock-social-button'); } diff --git a/test/functional/services/common/browser.ts b/test/functional/services/common/browser.ts index 6a49ae0a67ad..4462d4f31838 100644 --- a/test/functional/services/common/browser.ts +++ b/test/functional/services/common/browser.ts @@ -83,7 +83,7 @@ export async function BrowserProvider({ getService }: FtrProviderContext) { public async getAlert() { try { return await driver.switchTo().alert(); - } catch (e) { + } catch (e: any) { return null; } } diff --git a/test/functional/services/common/find.ts b/test/functional/services/common/find.ts index ee28fa02cc52..08e36a78de72 100644 --- a/test/functional/services/common/find.ts +++ b/test/functional/services/common/find.ts @@ -309,7 +309,7 @@ export async function FindProvider({ getService }: FtrProviderContext) { } else { return found instanceof WebElementWrapper; } - } catch (err) { + } catch (err: any) { await this._withTimeout(defaultFindTimeout); return false; } @@ -342,7 +342,7 @@ export async function FindProvider({ getService }: FtrProviderContext) { throw new Error(`${selector} is not displayed`); } }); - } catch (err) { + } catch (err: any) { await this._withTimeout(defaultFindTimeout); return false; } diff --git a/test/functional/services/common/screenshots.ts b/test/functional/services/common/screenshots.ts index 22b8d7796a69..f7a684238254 100644 --- a/test/functional/services/common/screenshots.ts +++ b/test/functional/services/common/screenshots.ts @@ -98,7 +98,7 @@ export async function ScreenshotsProvider({ getService }: FtrProviderContext) { const screenshot = await (el ? el.takeScreenshot() : browser.takeScreenshot()); await mkdirAsync(dirname(path), { recursive: true }); await writeFileAsync(path, screenshot, 'base64'); - } catch (err) { + } catch (err: any) { log.error('SCREENSHOT FAILED'); log.error(err); } diff --git a/test/functional/services/common/snapshots.ts b/test/functional/services/common/snapshots.ts index ecc84e6e9680..2d3521c37894 100644 --- a/test/functional/services/common/snapshots.ts +++ b/test/functional/services/common/snapshots.ts @@ -89,7 +89,7 @@ export async function SnapshotsProvider({ getService }: FtrProviderContext) { try { await mkdirAsync(dirname(path), { recursive: true }); await writeFileAsync(path, JSON.stringify(snapshot), 'utf8'); - } catch (err) { + } catch (err: any) { log.error('SNAPSHOT FAILED'); log.error(err); } diff --git a/test/functional/services/lib/web_element_wrapper/web_element_wrapper.ts b/test/functional/services/lib/web_element_wrapper/web_element_wrapper.ts index fa273b318a24..6a7c31bd26a9 100644 --- a/test/functional/services/lib/web_element_wrapper/web_element_wrapper.ts +++ b/test/functional/services/lib/web_element_wrapper/web_element_wrapper.ts @@ -130,7 +130,7 @@ export class WebElementWrapper { ): Promise { try { return await fn(this); - } catch (err) { + } catch (err: any) { const { name, message } = err as Error; if ( !RETRY_CLICK_RETRY_ON_ERRORS.includes(name) || diff --git a/test/functional/services/remote/prevent_parallel_calls.ts b/test/functional/services/remote/prevent_parallel_calls.ts index 0ce9791c4648..b89f52df4121 100644 --- a/test/functional/services/remote/prevent_parallel_calls.ts +++ b/test/functional/services/remote/prevent_parallel_calls.ts @@ -49,7 +49,7 @@ export function preventParallelCalls( public async exec() { try { this.resolve(await fn.call(this.context, this.arg)); - } catch (error) { + } catch (error: any) { this.reject(error); } finally { execQueue.shift(); diff --git a/test/functional/services/remote/remote.ts b/test/functional/services/remote/remote.ts index 1407578bf0e0..d5334fae97f6 100644 --- a/test/functional/services/remote/remote.ts +++ b/test/functional/services/remote/remote.ts @@ -42,7 +42,7 @@ export async function RemoteProvider({ getService }: FtrProviderContext) { const clearBrowserStorage = async (storageType: BrowserStorage) => { try { await driver.executeScript(`window.${storageType}.clear();`); - } catch (error) { + } catch (error: any) { if (!error.message.includes(`Failed to read the '${storageType}' property from 'Window'`)) { throw error; } diff --git a/test/interpreter_functional/plugins/osd_tp_run_pipeline/package.json b/test/interpreter_functional/plugins/osd_tp_run_pipeline/package.json index 45476309224d..7d374c4de0ca 100644 --- a/test/interpreter_functional/plugins/osd_tp_run_pipeline/package.json +++ b/test/interpreter_functional/plugins/osd_tp_run_pipeline/package.json @@ -16,6 +16,6 @@ "@osd/plugin-helpers": "1.0.0", "react": "^16.14.0", "react-dom": "^16.12.0", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/app_link_test/package.json b/test/plugin_functional/plugins/app_link_test/package.json index dd07b4de638c..76db24f60bd9 100644 --- a/test/plugin_functional/plugins/app_link_test/package.json +++ b/test/plugin_functional/plugins/app_link_test/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_app_status/package.json b/test/plugin_functional/plugins/core_app_status/package.json index 524e33d8dfb2..856fc55ad1bd 100644 --- a/test/plugin_functional/plugins/core_app_status/package.json +++ b/test/plugin_functional/plugins/core_app_status/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_a/package.json b/test/plugin_functional/plugins/core_plugin_a/package.json index b57d5783c77e..56d9ec25062c 100644 --- a/test/plugin_functional/plugins/core_plugin_a/package.json +++ b/test/plugin_functional/plugins/core_plugin_a/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_appleave/package.json b/test/plugin_functional/plugins/core_plugin_appleave/package.json index 5caa1a70f8d2..1a4dbf8f6804 100644 --- a/test/plugin_functional/plugins/core_plugin_appleave/package.json +++ b/test/plugin_functional/plugins/core_plugin_appleave/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_b/package.json b/test/plugin_functional/plugins/core_plugin_b/package.json index d37ffd582e6d..0b771f0e517a 100644 --- a/test/plugin_functional/plugins/core_plugin_b/package.json +++ b/test/plugin_functional/plugins/core_plugin_b/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_chromeless/package.json b/test/plugin_functional/plugins/core_plugin_chromeless/package.json index 0c444aaf80ca..4d3ab9438c08 100644 --- a/test/plugin_functional/plugins/core_plugin_chromeless/package.json +++ b/test/plugin_functional/plugins/core_plugin_chromeless/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_route_timeouts/package.json b/test/plugin_functional/plugins/core_plugin_route_timeouts/package.json index 1b03b60ad387..d00df8ccc539 100644 --- a/test/plugin_functional/plugins/core_plugin_route_timeouts/package.json +++ b/test/plugin_functional/plugins/core_plugin_route_timeouts/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_plugin_static_assets/package.json b/test/plugin_functional/plugins/core_plugin_static_assets/package.json index e44a09af12cb..f9c76e297ed8 100644 --- a/test/plugin_functional/plugins/core_plugin_static_assets/package.json +++ b/test/plugin_functional/plugins/core_plugin_static_assets/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/core_provider_plugin/package.json b/test/plugin_functional/plugins/core_provider_plugin/package.json index 778d9363e71d..949ba4d4790e 100644 --- a/test/plugin_functional/plugins/core_provider_plugin/package.json +++ b/test/plugin_functional/plugins/core_provider_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/data_search/package.json b/test/plugin_functional/plugins/data_search/package.json index 056a79f2139a..3b45e5346499 100644 --- a/test/plugin_functional/plugins/data_search/package.json +++ b/test/plugin_functional/plugins/data_search/package.json @@ -10,6 +10,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/doc_views_links_plugin/package.json b/test/plugin_functional/plugins/doc_views_links_plugin/package.json index 7cc258622ae8..28e06d621fe8 100644 --- a/test/plugin_functional/plugins/doc_views_links_plugin/package.json +++ b/test/plugin_functional/plugins/doc_views_links_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/doc_views_plugin/package.json b/test/plugin_functional/plugins/doc_views_plugin/package.json index 67018cec9d95..10fdc014836c 100644 --- a/test/plugin_functional/plugins/doc_views_plugin/package.json +++ b/test/plugin_functional/plugins/doc_views_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/index_patterns/package.json b/test/plugin_functional/plugins/index_patterns/package.json index 3b88f3bf3932..ae4de944f163 100644 --- a/test/plugin_functional/plugins/index_patterns/package.json +++ b/test/plugin_functional/plugins/index_patterns/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/management_test_plugin/package.json b/test/plugin_functional/plugins/management_test_plugin/package.json index b20971f403aa..44b8c7ed106c 100644 --- a/test/plugin_functional/plugins/management_test_plugin/package.json +++ b/test/plugin_functional/plugins/management_test_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/opensearch_client_plugin/package.json b/test/plugin_functional/plugins/opensearch_client_plugin/package.json index 77d31a85f8f5..a5b491a7cac2 100644 --- a/test/plugin_functional/plugins/opensearch_client_plugin/package.json +++ b/test/plugin_functional/plugins/opensearch_client_plugin/package.json @@ -10,6 +10,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/osd_sample_panel_action/package.json b/test/plugin_functional/plugins/osd_sample_panel_action/package.json index 34ebf31d78f6..4d6a5064f9cd 100644 --- a/test/plugin_functional/plugins/osd_sample_panel_action/package.json +++ b/test/plugin_functional/plugins/osd_sample_panel_action/package.json @@ -14,6 +14,6 @@ "devDependencies": { "@elastic/eui": "npm:@opensearch-project/oui@1.0.0", "react": "^16.14.0", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/osd_top_nav/package.json b/test/plugin_functional/plugins/osd_top_nav/package.json index a1a244da27cd..797f03d090a6 100644 --- a/test/plugin_functional/plugins/osd_top_nav/package.json +++ b/test/plugin_functional/plugins/osd_top_nav/package.json @@ -12,7 +12,7 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/osd_tp_custom_visualizations/package.json b/test/plugin_functional/plugins/osd_tp_custom_visualizations/package.json index 18961a35fda4..651edf40de40 100644 --- a/test/plugin_functional/plugins/osd_tp_custom_visualizations/package.json +++ b/test/plugin_functional/plugins/osd_tp_custom_visualizations/package.json @@ -15,6 +15,6 @@ "@elastic/eui": "npm:@opensearch-project/oui@1.0.0", "@osd/plugin-helpers": "1.0.0", "react": "^16.14.0", - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/rendering_plugin/package.json b/test/plugin_functional/plugins/rendering_plugin/package.json index 2548cfef508e..4f8ae54946f9 100644 --- a/test/plugin_functional/plugins/rendering_plugin/package.json +++ b/test/plugin_functional/plugins/rendering_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/test/plugin_functional/plugins/ui_settings_plugin/package.json b/test/plugin_functional/plugins/ui_settings_plugin/package.json index db9bedec26d0..c8dae3023f68 100644 --- a/test/plugin_functional/plugins/ui_settings_plugin/package.json +++ b/test/plugin_functional/plugins/ui_settings_plugin/package.json @@ -12,6 +12,6 @@ "build": "node ../../scripts/remove.js './target' && tsc" }, "devDependencies": { - "typescript": "4.0.2" + "typescript": "4.1.6" } } diff --git a/yarn.lock b/yarn.lock index 822684d097bd..f0b80ab1f638 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16566,11 +16566,6 @@ strip-json-comments@3.1.1, strip-json-comments@^3.0.1, strip-json-comments@^3.1. resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - strong-log-transformer@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/strong-log-transformer/-/strong-log-transformer-2.1.0.tgz#0f5ed78d325e0421ac6f90f7f10e691d6ae3ae10" @@ -17431,10 +17426,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@4.0.2, typescript@~4.5.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.6, typescript@~4.5.2: + version "4.1.6" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.6.tgz#1becd85d77567c3c741172339e93ce2e69932138" + integrity sha512-pxnwLxeb/Z5SP80JDRzVjh58KsM6jZHRAOtTpS7sXLS4ogXNKC9ANxHHZqLLeVHZN35jCtI4JdmLLbLiC1kBow== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6"