Skip to content

Commit

Permalink
fix TS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Oct 9, 2024
1 parent baaac48 commit 7419311
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/api/carto-api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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());
}
6 changes: 5 additions & 1 deletion src/api/request-with-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions src/sources/base-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
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);
Expand Down

0 comments on commit 7419311

Please sign in to comment.