From 86c34cc5494cce3c930e8da1860f54f0e210c936 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Dec 2024 11:02:31 +0000 Subject: [PATCH] Fix types --- packages/frontend-core/src/api/index.ts | 11 +++++------ packages/frontend-core/src/api/types.ts | 4 ++-- packages/frontend-core/tsconfig.json | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/frontend-core/src/api/index.ts b/packages/frontend-core/src/api/index.ts index bc55913d3a..23d8576e5b 100644 --- a/packages/frontend-core/src/api/index.ts +++ b/packages/frontend-core/src/api/index.ts @@ -108,7 +108,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { } // Performs an API call to the server. - const makeApiCall = async ( + const makeApiCall = async ( callConfig: APICallConfig ): Promise => { let { json, method, external, body, url, parseResponse, suppressErrors } = @@ -131,7 +131,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { } // Build request body - let requestBody: RequestT | string = body + let requestBody: any = body if (json) { try { requestBody = JSON.stringify(body) @@ -146,7 +146,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { response = await fetch(url, { method, headers, - body: requestBody as any, + body: requestBody, credentials: "same-origin", }) } catch (error) { @@ -187,7 +187,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { // Performs an API call to the server and caches the response. // Future invocation for this URL will return the cached result instead of // hitting the server again. - const makeCachedApiCall = async ( + const makeCachedApiCall = async ( callConfig: APICallConfig ): Promise => { const identifier = callConfig.url @@ -201,7 +201,7 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { // Constructs an API call function for a particular HTTP method const requestApiCall = (method: HTTPMethod) => - async ( + async ( params: APICallParams ): Promise => { try { @@ -211,7 +211,6 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => { suppressErrors: false, cache: false, method, - body: params.body, ...params, } let { url, cache, external } = callConfig diff --git a/packages/frontend-core/src/api/types.ts b/packages/frontend-core/src/api/types.ts index a887b67750..a2604a86fb 100644 --- a/packages/frontend-core/src/api/types.ts +++ b/packages/frontend-core/src/api/types.ts @@ -42,14 +42,14 @@ export type APIClientConfig = { onMigrationDetected?: (migration: string) => void } -export type APICallConfig = { +export type APICallConfig = { method: HTTPMethod url: string - body: RequestT json: boolean external: boolean suppressErrors: boolean cache: boolean + body?: RequestT parseResponse?: (response: Response) => Promise | ResponseT } diff --git a/packages/frontend-core/tsconfig.json b/packages/frontend-core/tsconfig.json index 506c8dfd5a..3900034413 100644 --- a/packages/frontend-core/tsconfig.json +++ b/packages/frontend-core/tsconfig.json @@ -2,10 +2,13 @@ "compilerOptions": { "target": "ESNext", "moduleResolution": "bundler", + "skipLibCheck": true, "paths": { "@budibase/types": ["../types/src"], "@budibase/shared-core": ["../shared-core/src"], "@budibase/bbui": ["../bbui/src"] } - } + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] }