diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index a4756390b6148822d2ebfcdc7bd91bea8e3a01ed..bf7f8f7b9250479856ce93c3a07b91bb40ac6191 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -81,7 +81,7 @@ async function getDockerApiTags( noAuth: true, }); tags = tags.concat(res.body.tags); - const linkHeader = parseLinkHeader(res.headers.link as string); + const linkHeader = parseLinkHeader(res.headers.link); url = linkHeader?.next ? URL.resolve(url, linkHeader.next.url) : null; page += 1; } while (url && page < 20); @@ -200,7 +200,8 @@ export async function getDigest( ); if (manifestResponse) { if (hasKey('docker-content-digest', manifestResponse.headers)) { - digest = manifestResponse.headers['docker-content-digest'] || null; + digest = + (manifestResponse.headers['docker-content-digest'] as string) || null; } else { logger.debug( { registryHost }, diff --git a/lib/datasource/maven/util.ts b/lib/datasource/maven/util.ts index a0e60610143242e746750485fecdf5d104da23a7..d3180042c263f1155a437d9a193475f9d5cace11 100644 --- a/lib/datasource/maven/util.ts +++ b/lib/datasource/maven/util.ts @@ -113,7 +113,7 @@ export async function checkHttpResource( try { const httpClient = httpByHostType(hostType); const res = await httpClient.head(pkgUrl.toString()); - const timestamp = res?.headers?.['last-modified'] as string; + const timestamp = res?.headers?.['last-modified']; if (timestamp) { const isoTimestamp = normalizeDate(timestamp); if (isoTimestamp) { diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 9168f725ef3d96c4b43f21c1966ab092d9dd14c3..4c06175bbb47f1262f91cb9206fa34cf1f13e65c 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -89,12 +89,13 @@ export async function detectGhe(token: string): Promise<void> { if (platformConfig.isGhe) { const gheHeaderKey = 'x-github-enterprise-version'; const gheQueryRes = await githubApi.headJson('/', { token }); - const gheHeaders: Record<string, string> = gheQueryRes?.headers || {}; + const gheHeaders: Record<string, string | string[]> = + gheQueryRes?.headers || {}; const [, gheVersion] = Object.entries(gheHeaders).find( ([k]) => k.toLowerCase() === gheHeaderKey ) ?? []; - platformConfig.gheVersion = semver.valid(gheVersion) ?? null; + platformConfig.gheVersion = semver.valid(gheVersion as string) ?? null; } } diff --git a/lib/util/http/gitlab.ts b/lib/util/http/gitlab.ts index 538837d2f1edfc070fe22e3f06b25841a6ed4c07..0dc537279d608c76008f8a450b23adea5d7e80af 100644 --- a/lib/util/http/gitlab.ts +++ b/lib/util/http/gitlab.ts @@ -40,7 +40,7 @@ export class GitlabHttp extends Http<GitlabHttpOptions, GitlabHttpOptions> { if (opts.paginate && is.array(result.body)) { // Check if result is paginated try { - const linkHeader = parseLinkHeader(result.headers.link as string); + const linkHeader = parseLinkHeader(result.headers.link); const nextUrl = linkHeader?.next?.url ? parseUrl(linkHeader.next.url) : null; diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts index 553e9126720e5caab28ea01e9ffda2ee0007b4d8..63f67fa73aefcbdbc70b610b89db7e9749feb621 100644 --- a/lib/util/http/index.ts +++ b/lib/util/http/index.ts @@ -1,4 +1,5 @@ import crypto from 'crypto'; +import type { IncomingHttpHeaders } from 'http'; import merge from 'deepmerge'; import got, { Options, Response } from 'got'; import { HOST_DISABLED } from '../../constants/error-messages'; @@ -48,10 +49,14 @@ export interface InternalHttpOptions extends HttpOptions { method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head'; } +export interface HttpHeaders extends IncomingHttpHeaders { + link?: string | undefined; +} + export interface HttpResponse<T = string> { statusCode: number; body: T; - headers: any; + headers: HttpHeaders; authorization?: boolean; }