From 74193117919a8a85db2f046b3d9a3869e5253ddd Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Wed, 9 Oct 2024 15:17:49 -0400 Subject: [PATCH] fix TS issues --- src/api/carto-api-error.ts | 6 +++--- src/api/request-with-parameters.ts | 6 +++++- src/sources/base-source.ts | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/api/carto-api-error.ts b/src/api/carto-api-error.ts index 0ed403a..d39c5f9 100644 --- a/src/api/carto-api-error.ts +++ b/src/api/carto-api-error.ts @@ -49,8 +49,8 @@ export class CartoAPIError extends Error { let message = `${errorContext.requestType} API request failed`; message += `\n${responseString}`; for (const key of Object.keys(errorContext)) { - if (key === 'requestType') continue; // eslint-disable-line no-continue - message += `\n${formatErrorKey(key)}: ${errorContext[key]}`; + if (key === 'requestType') continue; + message += `\n${formatErrorKey(key)}: ${(errorContext as any)[key]}`; } message += '\n'; @@ -67,6 +67,6 @@ export class CartoAPIError extends Error { /** * Converts camelCase to Camel Case */ -function formatErrorKey(key) { +function formatErrorKey(key: string) { return key.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase()); } diff --git a/src/api/request-with-parameters.ts b/src/api/request-with-parameters.ts index 759891e..8f8f4c4 100644 --- a/src/api/request-with-parameters.ts +++ b/src/api/request-with-parameters.ts @@ -5,7 +5,11 @@ import {isPureObject} from '../utils'; import {CartoAPIError} from './carto-api-error'; import type {APIErrorContext} from './types'; -import {DEFAULT_MAX_LENGTH_URL, V3_MINOR_VERSION} from '../constants'; +import { + DEFAULT_CLIENT, + DEFAULT_MAX_LENGTH_URL, + V3_MINOR_VERSION, +} from '../constants'; const DEFAULT_HEADERS = { Accept: 'application/json', diff --git a/src/sources/base-source.ts b/src/sources/base-source.ts index 39c9993..65c92e7 100644 --- a/src/sources/base-source.ts +++ b/src/sources/base-source.ts @@ -41,8 +41,9 @@ export async function baseSource>( endpoint, }; for (const key in optionalOptions) { - if (optionalOptions[key]) { - mergedOptions[key] = optionalOptions[key]; + if (optionalOptions[key as keyof typeof optionalOptions]) { + (mergedOptions as any)[key] = + optionalOptions[key as keyof typeof optionalOptions]; } } const baseUrl = buildSourceUrl(mergedOptions);