[8.0] replace any with unknown in http client and types (#114265) (#117524)

* replace any with unknown in http client and types (#114265)

# Conflicts:
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/components/suggestions_logic.tsx
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion_logic.ts
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings_logic.ts
#	x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.ts

* commit using @elastic.co
This commit is contained in:
Or Ouziel 2021-11-04 20:15:11 +02:00 committed by GitHub
parent 2ce0b8187a
commit 58f1af552e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
165 changed files with 724 additions and 421 deletions

View file

@ -8,7 +8,13 @@
import { IHttpFetchError } from 'kibana/public';
import { toasts, fatalError } from './notification';
function createToastConfig(error: IHttpFetchError, errorTitle: string) {
interface CommonErrorBody {
statusCode: number;
message: string;
error: string;
}
function createToastConfig(error: IHttpFetchError<CommonErrorBody>, errorTitle: string) {
// Expect an error in the shape provided by http service.
if (error && error.body) {
const { error: errorString, statusCode, message } = error.body;
@ -19,7 +25,7 @@ function createToastConfig(error: IHttpFetchError, errorTitle: string) {
}
}
export function showApiWarning(error: IHttpFetchError, errorTitle: string) {
export function showApiWarning(error: IHttpFetchError<CommonErrorBody>, errorTitle: string) {
const toastConfig = createToastConfig(error, errorTitle);
if (toastConfig) {
@ -31,7 +37,7 @@ export function showApiWarning(error: IHttpFetchError, errorTitle: string) {
return fatalError.add(error, errorTitle);
}
export function showApiError(error: IHttpFetchError, errorTitle: string) {
export function showApiError(error: IHttpFetchError<CommonErrorBody>, errorTitle: string) {
const toastConfig = createToastConfig(error, errorTitle);
if (toastConfig) {