From 7daa93a78dca223b3e52aa99e7c3fae168d7975f Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Tue, 11 May 2021 12:51:21 +0200
Subject: [PATCH] refactor: extract types to new files (#9951)

---
 lib/config/cli.ts                             |  6 +--
 lib/config/migration.spec.ts                  | 36 ++++++++--------
 lib/config/migration.ts                       | 22 +++-------
 lib/config/presets/index.ts                   | 10 +----
 lib/config/presets/types.ts                   |  8 ++++
 lib/config/types.ts                           | 23 ++++++++++
 lib/config/validation-helpers/managers.ts     |  8 +---
 lib/config/validation-helpers/types.ts        |  6 +++
 lib/config/validation.ts                      |  6 +--
 lib/datasource/cdnjs/index.ts                 | 16 +------
 lib/datasource/cdnjs/types.ts                 | 14 ++++++
 lib/datasource/crate/index.spec.ts            |  9 +---
 lib/datasource/crate/index.ts                 | 30 +------------
 lib/datasource/crate/types.ts                 | 28 ++++++++++++
 lib/datasource/dart/index.ts                  | 10 +----
 lib/datasource/dart/types.ts                  |  9 ++++
 lib/datasource/docker/index.ts                |  7 +--
 lib/datasource/docker/types.ts                |  5 +++
 lib/datasource/git-refs/index.ts              |  7 +--
 lib/datasource/git-refs/types.ts              |  5 +++
 lib/datasource/git-tags/index.ts              |  4 +-
 lib/datasource/github-tags/index.ts           |  9 +---
 lib/datasource/github-tags/types.ts           |  7 +++
 lib/datasource/go/index.ts                    |  7 +--
 lib/datasource/go/types.ts                    |  5 +++
 lib/datasource/helm/index.ts                  | 20 ++-------
 lib/datasource/helm/types.ts                  | 15 +++++++
 lib/datasource/hex/index.ts                   | 10 +----
 lib/datasource/hex/types.ts                   |  8 ++++
 lib/datasource/jenkins-plugins/get.ts         | 36 +++-------------
 lib/datasource/jenkins-plugins/types.ts       | 31 +++++++++++++
 lib/datasource/npm/get.ts                     | 17 +-------
 lib/datasource/npm/npmrc.ts                   |  9 +---
 lib/datasource/npm/types.ts                   | 25 +++++++++++
 lib/datasource/nuget/types.ts                 | 24 +++++++++++
 lib/datasource/nuget/v2.ts                    |  1 -
 lib/datasource/nuget/v3.ts                    | 36 ++++------------
 lib/datasource/orb/index.ts                   |  9 +---
 lib/datasource/orb/types.ts                   |  7 +++
 lib/datasource/packagist/index.ts             | 43 +++----------------
 lib/datasource/packagist/types.ts             | 35 +++++++++++++++
 lib/datasource/repology/index.spec.ts         |  3 +-
 lib/datasource/repology/index.ts              | 13 +-----
 lib/datasource/repology/types.ts              | 10 +++++
 lib/datasource/terraform-module/index.ts      | 25 +++--------
 lib/datasource/terraform-module/types.ts      | 19 ++++++++
 lib/datasource/terraform-provider/index.ts    | 25 ++---------
 lib/datasource/terraform-provider/types.ts    | 20 +++++++++
 lib/logger/index.ts                           | 25 +----------
 lib/logger/pretty-stdout.spec.ts              |  2 +-
 lib/logger/pretty-stdout.ts                   |  2 +-
 lib/logger/types.ts                           | 34 +++++++++++++++
 lib/logger/utils.ts                           | 16 ++-----
 lib/util/cache/package/index.ts               |  2 +-
 .../cache/package/{common.ts => types.ts}     |  0
 lib/util/cache/repository/index.ts            |  2 +-
 lib/workers/repository/init/merge.ts          |  2 +-
 .../repository/init/{common.ts => types.ts}   |  0
 58 files changed, 430 insertions(+), 393 deletions(-)
 create mode 100644 lib/config/validation-helpers/types.ts
 create mode 100644 lib/datasource/cdnjs/types.ts
 create mode 100644 lib/datasource/crate/types.ts
 create mode 100644 lib/datasource/dart/types.ts
 create mode 100644 lib/datasource/git-refs/types.ts
 create mode 100644 lib/datasource/github-tags/types.ts
 create mode 100644 lib/datasource/go/types.ts
 create mode 100644 lib/datasource/helm/types.ts
 create mode 100644 lib/datasource/hex/types.ts
 create mode 100644 lib/datasource/jenkins-plugins/types.ts
 create mode 100644 lib/datasource/nuget/types.ts
 create mode 100644 lib/datasource/orb/types.ts
 create mode 100644 lib/datasource/packagist/types.ts
 create mode 100644 lib/datasource/repology/types.ts
 create mode 100644 lib/datasource/terraform-module/types.ts
 create mode 100644 lib/datasource/terraform-provider/types.ts
 create mode 100644 lib/logger/types.ts
 rename lib/util/cache/package/{common.ts => types.ts} (100%)
 rename lib/workers/repository/init/{common.ts => types.ts} (100%)

diff --git a/lib/config/cli.ts b/lib/config/cli.ts
index 02e0edb676..1c6c371de7 100644
--- a/lib/config/cli.ts
+++ b/lib/config/cli.ts
@@ -1,7 +1,7 @@
 import { Command } from 'commander';
 import { version } from '../../package.json';
 import { getOptions } from './definitions';
-import type { GlobalConfig, RenovateOptions } from './types';
+import type { GlobalConfig, RenovateCliConfig, RenovateOptions } from './types';
 
 export function getCliName(option: Partial<RenovateOptions>): string {
   if (option.cli === false) {
@@ -11,10 +11,6 @@ export function getCliName(option: Partial<RenovateOptions>): string {
   return `--${nameWithHyphens.toLowerCase()}`;
 }
 
-export interface RenovateCliConfig extends Record<string, any> {
-  repositories?: string[];
-}
-
 export function getConfig(input: string[]): GlobalConfig {
   // massage migrated configuration keys
   const argv = input
diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts
index 29fffe448e..7dcd84fbf2 100644
--- a/lib/config/migration.spec.ts
+++ b/lib/config/migration.spec.ts
@@ -2,22 +2,22 @@ import { getName } from '../../test/util';
 import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
 import { getConfig } from './defaults';
 import * as configMigration from './migration';
-import { MigratedConfig } from './migration';
 import type {
+  MigratedConfig,
+  RenovateConfig,
   RenovateSharedConfig,
-  RenovateConfig as _RenovateConfig,
 } from './types';
 
 const defaultConfig = getConfig();
 
-interface RenovateConfig extends _RenovateConfig {
+interface TestRenovateConfig extends RenovateConfig {
   node?: RenovateSharedConfig & { supportPolicy?: unknown };
 }
 
 describe(getName(), () => {
   describe('migrateConfig(config, parentConfig)', () => {
     it('migrates config', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         endpoints: [{}] as never,
         enabled: true,
         platform: PLATFORM_TYPE_GITHUB,
@@ -275,7 +275,7 @@ describe(getName(), () => {
       expect(migratedConfig).toMatchSnapshot();
     });
     it('overrides existing automerge setting', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         automerge: 'minor' as never,
         packages: [
           {
@@ -294,7 +294,7 @@ describe(getName(), () => {
       expect(migratedConfig.packageRules[0].minor.automerge).toBe(false);
     });
     it('does not migrate config', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         enabled: true,
         separateMinorPatch: true,
       };
@@ -305,7 +305,7 @@ describe(getName(), () => {
       expect(migratedConfig).toMatchObject(config);
     });
     it('migrates subconfig', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         lockFileMaintenance: {
           depTypes: [
             'dependencies',
@@ -346,7 +346,7 @@ describe(getName(), () => {
       expect(migratedConfig.packageRules).toHaveLength(1);
     });
     it('migrates node to travis', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         node: {
           enabled: true,
           supportPolicy: ['lts'],
@@ -366,11 +366,11 @@ describe(getName(), () => {
         true
       );
       expect(
-        (migratedConfig.node as RenovateConfig).supportPolicy
+        (migratedConfig.node as TestRenovateConfig).supportPolicy
       ).toBeDefined();
     });
     it('migrates packageFiles', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         packageFiles: [
           'package.json',
           { packageFile: 'backend/package.json', pinVersions: false },
@@ -395,7 +395,7 @@ describe(getName(), () => {
       expect(migratedConfig.packageRules[1].rangeStrategy).toBe('pin');
     });
     it('migrates more packageFiles', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         packageFiles: [
           {
             packageFile: 'package.json',
@@ -424,7 +424,7 @@ describe(getName(), () => {
     });
 
     it('removes invalid configs', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         pathRules: {},
         packageFiles: [{ packageFile: 'test' }],
         gomodTidy: false,
@@ -448,7 +448,7 @@ describe(getName(), () => {
       expect(isMigrated).toBe(true);
     });
     it('it migrates semanticCommits', () => {
-      let config: RenovateConfig;
+      let config: TestRenovateConfig;
       let res: MigratedConfig;
 
       config = { semanticCommits: true as never };
@@ -478,7 +478,7 @@ describe(getName(), () => {
     });
 
     it('it migrates preset strings to array', () => {
-      let config: RenovateConfig;
+      let config: TestRenovateConfig;
       let res: MigratedConfig;
 
       config = { extends: ':js-app' } as never;
@@ -500,7 +500,7 @@ describe(getName(), () => {
     });
 
     it('it migrates unpublishSafe', () => {
-      let config: RenovateConfig;
+      let config: TestRenovateConfig;
       let res: MigratedConfig;
 
       config = { unpublishSafe: true };
@@ -582,7 +582,7 @@ describe(getName(), () => {
       });
     });
     it('migrates combinations of packageRules', () => {
-      let config: RenovateConfig;
+      let config: TestRenovateConfig;
       let res: MigratedConfig;
 
       config = {
@@ -602,7 +602,7 @@ describe(getName(), () => {
       expect(res.migratedConfig.packageRules).toHaveLength(2);
     });
     it('it migrates packageRules', () => {
-      const config: RenovateConfig = {
+      const config: TestRenovateConfig = {
         packageRules: [
           {
             paths: ['package.json'],
@@ -629,7 +629,7 @@ describe(getName(), () => {
     });
   });
   it('it migrates nested packageRules', () => {
-    const config: RenovateConfig = {
+    const config: TestRenovateConfig = {
       packageRules: [
         {
           matchDepTypes: ['devDependencies'],
diff --git a/lib/config/migration.ts b/lib/config/migration.ts
index 908448c0c1..09bc1d87b1 100644
--- a/lib/config/migration.ts
+++ b/lib/config/migration.ts
@@ -2,11 +2,15 @@ import later from '@breejs/later';
 import is from '@sindresorhus/is';
 import { dequal } from 'dequal';
 import { logger } from '../logger';
-import type { HostRule } from '../types';
 import { clone } from '../util/clone';
 import { getOptions } from './definitions';
 import { removedPresets } from './presets/common';
-import type { PackageRule, RenovateConfig, RenovateOptions } from './types';
+import type {
+  MigratedConfig,
+  MigratedRenovateConfig,
+  RenovateConfig,
+  RenovateOptions,
+} from './types';
 import { mergeChildConfig } from './utils';
 
 const options = getOptions();
@@ -29,20 +33,6 @@ const removedOptions = [
   'lazyGrouping',
 ];
 
-export interface MigratedConfig {
-  isMigrated: boolean;
-  migratedConfig: RenovateConfig;
-}
-
-interface MigratedRenovateConfig extends RenovateConfig {
-  endpoints?: HostRule[];
-  pathRules: PackageRule[];
-  packages: PackageRule[];
-
-  node?: RenovateConfig;
-  travis?: RenovateConfig;
-}
-
 // Returns a migrated config
 export function migrateConfig(
   config: RenovateConfig,
diff --git a/lib/config/presets/index.ts b/lib/config/presets/index.ts
index 7e71fc68e1..a4afb939aa 100644
--- a/lib/config/presets/index.ts
+++ b/lib/config/presets/index.ts
@@ -17,7 +17,7 @@ import * as gitlab from './gitlab';
 import * as internal from './internal';
 import * as local from './local';
 import * as npm from './npm';
-import type { PresetApi } from './types';
+import type { ParsedPreset, PresetApi } from './types';
 import {
   PRESET_DEP_NOT_FOUND,
   PRESET_INVALID,
@@ -345,11 +345,3 @@ export async function resolveConfigPresets(
   logger.trace({ config }, 'Resolved config');
   return config;
 }
-
-export interface ParsedPreset {
-  presetSource: string;
-  packageName: string;
-  presetPath?: string;
-  presetName: string;
-  params?: string[];
-}
diff --git a/lib/config/presets/types.ts b/lib/config/presets/types.ts
index 7296dda27a..329f933e65 100644
--- a/lib/config/presets/types.ts
+++ b/lib/config/presets/types.ts
@@ -13,3 +13,11 @@ export type PresetConfig = {
 export interface PresetApi {
   getPreset(config: PresetConfig): Promise<Preset> | Preset;
 }
+
+export interface ParsedPreset {
+  presetSource: string;
+  packageName: string;
+  presetPath?: string;
+  presetName: string;
+  params?: string[];
+}
diff --git a/lib/config/types.ts b/lib/config/types.ts
index cbbbd97337..151702c58a 100644
--- a/lib/config/types.ts
+++ b/lib/config/types.ts
@@ -357,3 +357,26 @@ export interface ManagerConfig extends RenovateConfig {
   language: string;
   manager: string;
 }
+
+export interface RenovateCliConfig extends Record<string, any> {
+  repositories?: string[];
+}
+
+export interface MigratedConfig {
+  isMigrated: boolean;
+  migratedConfig: RenovateConfig;
+}
+
+export interface MigratedRenovateConfig extends RenovateConfig {
+  endpoints?: HostRule[];
+  pathRules: PackageRule[];
+  packages: PackageRule[];
+
+  node?: RenovateConfig;
+  travis?: RenovateConfig;
+}
+
+export interface ValidationResult {
+  errors: ValidationMessage[];
+  warnings: ValidationMessage[];
+}
diff --git a/lib/config/validation-helpers/managers.ts b/lib/config/validation-helpers/managers.ts
index e8849b88e7..2f2774c73a 100644
--- a/lib/config/validation-helpers/managers.ts
+++ b/lib/config/validation-helpers/managers.ts
@@ -1,10 +1,6 @@
 import { getManagerList } from '../../manager';
-import type { PackageRule, ValidationMessage } from '../types';
-
-export interface CheckManagerArgs {
-  resolvedRule: PackageRule;
-  currentPath: string;
-}
+import type { ValidationMessage } from '../types';
+import type { CheckManagerArgs } from './types';
 
 /**
  * Only if type condition or context condition violated then errors array will be mutated to store metadata
diff --git a/lib/config/validation-helpers/types.ts b/lib/config/validation-helpers/types.ts
new file mode 100644
index 0000000000..05f70826cf
--- /dev/null
+++ b/lib/config/validation-helpers/types.ts
@@ -0,0 +1,6 @@
+import type { PackageRule } from '../types';
+
+export interface CheckManagerArgs {
+  resolvedRule: PackageRule;
+  currentPath: string;
+}
diff --git a/lib/config/validation.ts b/lib/config/validation.ts
index 93c13065b5..e7f880fb5f 100644
--- a/lib/config/validation.ts
+++ b/lib/config/validation.ts
@@ -10,6 +10,7 @@ import type {
   RenovateConfig,
   RenovateOptions,
   ValidationMessage,
+  ValidationResult,
 } from './types';
 import * as managerValidator from './validation-helpers/managers';
 
@@ -18,11 +19,6 @@ const options = getOptions();
 let optionTypes: Record<string, RenovateOptions['type']>;
 let optionParents: Record<string, RenovateOptions['parent']>;
 
-export interface ValidationResult {
-  errors: ValidationMessage[];
-  warnings: ValidationMessage[];
-}
-
 const managerList = getManagerList();
 
 function isManagerPath(parentPath: string): boolean {
diff --git a/lib/datasource/cdnjs/index.ts b/lib/datasource/cdnjs/index.ts
index e678e56ecd..7ac03579c4 100644
--- a/lib/datasource/cdnjs/index.ts
+++ b/lib/datasource/cdnjs/index.ts
@@ -1,6 +1,7 @@
 import { ExternalHostError } from '../../types/errors/external-host-error';
 import { Http } from '../../util/http';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { CdnjsResponse } from './types';
 
 export const id = 'cdnjs';
 export const customRegistrySupport = false;
@@ -9,21 +10,6 @@ export const caching = true;
 
 const http = new Http(id);
 
-interface CdnjsAsset {
-  version: string;
-  files: string[];
-  sri?: Record<string, string>;
-}
-
-interface CdnjsResponse {
-  homepage?: string;
-  repository?: {
-    type: 'git' | unknown;
-    url?: string;
-  };
-  assets?: CdnjsAsset[];
-}
-
 export async function getReleases({
   lookupName,
   registryUrl,
diff --git a/lib/datasource/cdnjs/types.ts b/lib/datasource/cdnjs/types.ts
new file mode 100644
index 0000000000..97ff84563d
--- /dev/null
+++ b/lib/datasource/cdnjs/types.ts
@@ -0,0 +1,14 @@
+interface CdnjsAsset {
+  version: string;
+  files: string[];
+  sri?: Record<string, string>;
+}
+
+export interface CdnjsResponse {
+  homepage?: string;
+  repository?: {
+    type: 'git' | unknown;
+    url?: string;
+  };
+  assets?: CdnjsAsset[];
+}
diff --git a/lib/datasource/crate/index.spec.ts b/lib/datasource/crate/index.spec.ts
index 78bf915b7c..4e00641136 100644
--- a/lib/datasource/crate/index.spec.ts
+++ b/lib/datasource/crate/index.spec.ts
@@ -9,13 +9,8 @@ import { getName, loadFixture } from '../../../test/util';
 import { setAdminConfig } from '../../config/admin';
 import * as memCache from '../../util/cache/memory';
 import { setFsConfig } from '../../util/fs';
-import {
-  RegistryFlavor,
-  RegistryInfo,
-  id as datasource,
-  fetchCrateRecordsPayload,
-  getIndexSuffix,
-} from '.';
+import { RegistryFlavor, RegistryInfo } from './types';
+import { id as datasource, fetchCrateRecordsPayload, getIndexSuffix } from '.';
 
 jest.mock('simple-git');
 const simpleGit: any = _simpleGit;
diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts
index 44d39cb185..87108e683e 100644
--- a/lib/datasource/crate/index.ts
+++ b/lib/datasource/crate/index.ts
@@ -10,6 +10,7 @@ import { privateCacheDir, readFile } from '../../util/fs';
 import { Http } from '../../util/http';
 import * as cargoVersioning from '../../versioning/cargo';
 import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
+import { CrateRecord, RegistryFlavor, RegistryInfo } from './types';
 
 export const id = 'crate';
 export const customRegistrySupport = true;
@@ -22,30 +23,6 @@ const http = new Http(id);
 const CRATES_IO_BASE_URL =
   'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/';
 
-export enum RegistryFlavor {
-  /** https://crates.io, supports rawgit access */
-  CratesIo,
-
-  /** https://cloudsmith.io, needs git clone */
-  Cloudsmith,
-
-  /** unknown, assuming private git repository */
-  Other,
-}
-
-export interface RegistryInfo {
-  flavor: RegistryFlavor;
-
-  /** raw URL of the registry, as specified in cargo config */
-  rawUrl?: string;
-
-  /** parsed URL of the registry */
-  url?: URL;
-
-  /** path where the registry is cloned */
-  clonePath?: string;
-}
-
 export function getIndexSuffix(lookupName: string): string[] {
   const len = lookupName.length;
 
@@ -62,11 +39,6 @@ export function getIndexSuffix(lookupName: string): string[] {
   return [lookupName.slice(0, 2), lookupName.slice(2, 4), lookupName];
 }
 
-interface CrateRecord {
-  vers: string;
-  yanked: boolean;
-}
-
 export async function fetchCrateRecordsPayload(
   info: RegistryInfo,
   lookupName: string
diff --git a/lib/datasource/crate/types.ts b/lib/datasource/crate/types.ts
new file mode 100644
index 0000000000..187a38edff
--- /dev/null
+++ b/lib/datasource/crate/types.ts
@@ -0,0 +1,28 @@
+export enum RegistryFlavor {
+  /** https://crates.io, supports rawgit access */
+  CratesIo,
+
+  /** https://cloudsmith.io, needs git clone */
+  Cloudsmith,
+
+  /** unknown, assuming private git repository */
+  Other,
+}
+
+export interface RegistryInfo {
+  flavor: RegistryFlavor;
+
+  /** raw URL of the registry, as specified in cargo config */
+  rawUrl?: string;
+
+  /** parsed URL of the registry */
+  url?: URL;
+
+  /** path where the registry is cloned */
+  clonePath?: string;
+}
+
+export interface CrateRecord {
+  vers: string;
+  yanked: boolean;
+}
diff --git a/lib/datasource/dart/index.ts b/lib/datasource/dart/index.ts
index 2df5e62320..c42c1fdcc2 100644
--- a/lib/datasource/dart/index.ts
+++ b/lib/datasource/dart/index.ts
@@ -1,6 +1,7 @@
 import { ExternalHostError } from '../../types/errors/external-host-error';
 import { Http, HttpResponse } from '../../util/http';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { DartResult } from './types';
 
 export const id = 'dart';
 export const defaultRegistryUrls = ['https://pub.dartlang.org/'];
@@ -14,15 +15,6 @@ export async function getReleases({
 }: GetReleasesConfig): Promise<ReleaseResult | null> {
   let result: ReleaseResult = null;
   const pkgUrl = `${registryUrl}api/packages/${lookupName}`;
-  interface DartResult {
-    versions?: {
-      version: string;
-      published?: string;
-    }[];
-    latest?: {
-      pubspec?: { homepage?: string; repository?: string };
-    };
-  }
 
   let raw: HttpResponse<DartResult> = null;
   try {
diff --git a/lib/datasource/dart/types.ts b/lib/datasource/dart/types.ts
new file mode 100644
index 0000000000..735e45f263
--- /dev/null
+++ b/lib/datasource/dart/types.ts
@@ -0,0 +1,9 @@
+export interface DartResult {
+  versions?: {
+    version: string;
+    published?: string;
+  }[];
+  latest?: {
+    pubspec?: { homepage?: string; repository?: string };
+  };
+}
diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts
index 925258b5b8..20869bad55 100644
--- a/lib/datasource/docker/index.ts
+++ b/lib/datasource/docker/index.ts
@@ -14,7 +14,7 @@ import type { OutgoingHttpHeaders } from '../../util/http/types';
 import { ensureTrailingSlash, trimTrailingSlash } from '../../util/url';
 import * as dockerVersioning from '../../versioning/docker';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
-import { Image, ImageList, MediaType } from './types';
+import { Image, ImageList, MediaType, RegistryRepository } from './types';
 
 // TODO: add got typings when available (#9646)
 // TODO: replace www-authenticate with https://www.npmjs.com/package/auth-header (#9645)
@@ -56,11 +56,6 @@ const http = new Http(id);
 
 const ecrRegex = /\d+\.dkr\.ecr\.([-a-z0-9]+)\.amazonaws\.com/;
 
-export interface RegistryRepository {
-  registry: string;
-  repository: string;
-}
-
 export function getRegistryRepository(
   lookupName: string,
   registryUrl: string
diff --git a/lib/datasource/docker/types.ts b/lib/datasource/docker/types.ts
index 92a7458e9b..4b5e3db207 100644
--- a/lib/datasource/docker/types.ts
+++ b/lib/datasource/docker/types.ts
@@ -40,3 +40,8 @@ export interface Image extends MediaObject {
 
   readonly config: MediaObject;
 }
+
+export interface RegistryRepository {
+  registry: string;
+  repository: string;
+}
diff --git a/lib/datasource/git-refs/index.ts b/lib/datasource/git-refs/index.ts
index b8bc26a4ab..e814bb59e5 100644
--- a/lib/datasource/git-refs/index.ts
+++ b/lib/datasource/git-refs/index.ts
@@ -3,6 +3,7 @@ import * as packageCache from '../../util/cache/package';
 import { getRemoteUrlWithToken } from '../../util/git/url';
 import * as semver from '../../versioning/semver';
 import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
+import type { RawRefs } from './types';
 
 export const id = 'git-refs';
 export const customRegistrySupport = false;
@@ -12,12 +13,6 @@ const cacheMinutes = 10;
 // git will prompt for known hosts or passwords, unless we activate BatchMode
 process.env.GIT_SSH_COMMAND = 'ssh -o BatchMode=yes';
 
-export interface RawRefs {
-  type: string;
-  value: string;
-  hash: string;
-}
-
 export async function getRawRefs({
   lookupName,
 }: GetReleasesConfig): Promise<RawRefs[] | null> {
diff --git a/lib/datasource/git-refs/types.ts b/lib/datasource/git-refs/types.ts
new file mode 100644
index 0000000000..93b24abf03
--- /dev/null
+++ b/lib/datasource/git-refs/types.ts
@@ -0,0 +1,5 @@
+export interface RawRefs {
+  type: string;
+  value: string;
+  hash: string;
+}
diff --git a/lib/datasource/git-tags/index.ts b/lib/datasource/git-tags/index.ts
index ce1fd14975..b0a3956de2 100644
--- a/lib/datasource/git-tags/index.ts
+++ b/lib/datasource/git-tags/index.ts
@@ -8,7 +8,7 @@ export const customRegistrySupport = false;
 export async function getReleases({
   lookupName,
 }: GetReleasesConfig): Promise<ReleaseResult | null> {
-  const rawRefs: gitRefs.RawRefs[] = await gitRefs.getRawRefs({ lookupName });
+  const rawRefs = await gitRefs.getRawRefs({ lookupName });
 
   if (rawRefs === null) {
     return null;
@@ -36,7 +36,7 @@ export async function getDigest(
   { lookupName }: Partial<DigestConfig>,
   newValue?: string
 ): Promise<string | null> {
-  const rawRefs: gitRefs.RawRefs[] = await gitRefs.getRawRefs({ lookupName });
+  const rawRefs = await gitRefs.getRawRefs({ lookupName });
   const findValue = newValue || 'HEAD';
   const ref = rawRefs.find((rawRef) => rawRef.value === findValue);
   if (ref) {
diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts
index ac3b93c528..1801050c2b 100644
--- a/lib/datasource/github-tags/index.ts
+++ b/lib/datasource/github-tags/index.ts
@@ -4,6 +4,7 @@ import { GithubHttp } from '../../util/http/github';
 import { ensureTrailingSlash } from '../../util/url';
 import * as githubReleases from '../github-releases';
 import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
+import type { TagResponse } from './types';
 
 export const id = 'github-tags';
 export const customRegistrySupport = true;
@@ -17,14 +18,6 @@ function getCacheKey(registryUrl: string, repo: string, type: string): string {
   return `${registryUrl}:${repo}:${type}`;
 }
 
-interface TagResponse {
-  object: {
-    type: string;
-    url: string;
-    sha: string;
-  };
-}
-
 async function getTagCommit(
   registryUrl: string,
   githubRepo: string,
diff --git a/lib/datasource/github-tags/types.ts b/lib/datasource/github-tags/types.ts
new file mode 100644
index 0000000000..0c570048a2
--- /dev/null
+++ b/lib/datasource/github-tags/types.ts
@@ -0,0 +1,7 @@
+export interface TagResponse {
+  object: {
+    type: string;
+    url: string;
+    sha: string;
+  };
+}
diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts
index a8372bdbc9..dcfd42eef5 100644
--- a/lib/datasource/go/index.ts
+++ b/lib/datasource/go/index.ts
@@ -9,6 +9,7 @@ import * as bitbucket from '../bitbucket-tags';
 import * as github from '../github-tags';
 import * as gitlab from '../gitlab-tags';
 import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
+import type { DataSource } from './types';
 
 export const id = 'go';
 export const customRegistrySupport = false;
@@ -16,12 +17,6 @@ export const customRegistrySupport = false;
 const http = new Http(id);
 const gitlabRegExp = /^(https:\/\/[^/]*gitlab.[^/]*)\/(.*)$/;
 
-interface DataSource {
-  datasource: string;
-  registryUrl?: string;
-  lookupName: string;
-}
-
 async function getDatasource(goModule: string): Promise<DataSource | null> {
   if (goModule.startsWith('gopkg.in/')) {
     const [pkg] = goModule.replace('gopkg.in/', '').split('.');
diff --git a/lib/datasource/go/types.ts b/lib/datasource/go/types.ts
new file mode 100644
index 0000000000..c333c22e6a
--- /dev/null
+++ b/lib/datasource/go/types.ts
@@ -0,0 +1,5 @@
+export interface DataSource {
+  datasource: string;
+  registryUrl?: string;
+  lookupName: string;
+}
diff --git a/lib/datasource/helm/index.ts b/lib/datasource/helm/index.ts
index af28e7caee..269189702f 100644
--- a/lib/datasource/helm/index.ts
+++ b/lib/datasource/helm/index.ts
@@ -7,6 +7,7 @@ import * as packageCache from '../../util/cache/package';
 import { Http } from '../../util/http';
 import { ensureTrailingSlash } from '../../util/url';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { HelmRepository, RepositoryData } from './types';
 
 export const id = 'helm';
 
@@ -23,8 +24,6 @@ export const defaultConfig = {
   },
 };
 
-export type RepositoryData = Record<string, ReleaseResult>;
-
 export async function getRepositoryData(
   repository: string
 ): Promise<RepositoryData> {
@@ -57,21 +56,10 @@ export async function getRepositoryData(
     throw err;
   }
   try {
-    interface HelmRepository {
-      entries: Record<
-        string,
-        {
-          home?: string;
-          sources?: string[];
-          version: string;
-          created: string;
-        }[]
-      >;
-    }
-    const doc: HelmRepository = yaml.safeLoad(res.body, {
+    const doc = yaml.safeLoad(res.body, {
       json: true,
-    }) as any;
-    if (!is.plainObject<Record<string, unknown>>(doc)) {
+    }) as HelmRepository;
+    if (!is.plainObject<HelmRepository>(doc)) {
       logger.warn(`Failed to parse index.yaml from ${repository}`);
       return null;
     }
diff --git a/lib/datasource/helm/types.ts b/lib/datasource/helm/types.ts
new file mode 100644
index 0000000000..2f3877706b
--- /dev/null
+++ b/lib/datasource/helm/types.ts
@@ -0,0 +1,15 @@
+import type { ReleaseResult } from '../types';
+
+export interface HelmRepository {
+  entries: Record<
+    string,
+    {
+      home?: string;
+      sources?: string[];
+      version: string;
+      created: string;
+    }[]
+  >;
+}
+
+export type RepositoryData = Record<string, ReleaseResult>;
diff --git a/lib/datasource/hex/index.ts b/lib/datasource/hex/index.ts
index a9eaa5b084..9704251be5 100644
--- a/lib/datasource/hex/index.ts
+++ b/lib/datasource/hex/index.ts
@@ -3,6 +3,7 @@ import { ExternalHostError } from '../../types/errors/external-host-error';
 import { Http } from '../../util/http';
 import * as hexVersioning from '../../versioning/hex';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { HexRelease } from './types';
 
 export const id = 'hex';
 export const defaultRegistryUrls = ['https://hex.pm/'];
@@ -11,15 +12,6 @@ export const defaultVersioning = hexVersioning.id;
 
 const http = new Http(id);
 
-interface HexRelease {
-  html_url: string;
-  meta?: { links?: Record<string, string> };
-  releases?: {
-    version: string;
-    inserted_at?: string;
-  }[];
-}
-
 export async function getReleases({
   lookupName,
   registryUrl,
diff --git a/lib/datasource/hex/types.ts b/lib/datasource/hex/types.ts
new file mode 100644
index 0000000000..bf7eadc797
--- /dev/null
+++ b/lib/datasource/hex/types.ts
@@ -0,0 +1,8 @@
+export interface HexRelease {
+  html_url: string;
+  meta?: { links?: Record<string, string> };
+  releases?: {
+    version: string;
+    inserted_at?: string;
+  }[];
+}
diff --git a/lib/datasource/jenkins-plugins/get.ts b/lib/datasource/jenkins-plugins/get.ts
index 3ebe7c804e..14b517d6a8 100644
--- a/lib/datasource/jenkins-plugins/get.ts
+++ b/lib/datasource/jenkins-plugins/get.ts
@@ -5,6 +5,12 @@ import { getElapsedMinutes } from '../../util/date';
 import { Http } from '../../util/http';
 import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
 import { id } from './common';
+import type {
+  JenkinsCache,
+  JenkinsCacheTypes,
+  JenkinsPluginsInfoResponse,
+  JenkinsPluginsVersionsResponse,
+} from './types';
 
 const http = new Http(id);
 
@@ -13,36 +19,6 @@ const packageInfoUrl =
 const packageVersionsUrl =
   'https://updates.jenkins.io/current/plugin-versions.json';
 
-type JenkinsCacheTypes = ReleaseResult | Release[];
-
-interface JenkinsCache<T> {
-  name: string;
-  dataUrl: string;
-  lastSync: Date;
-  cacheTimeMin: number;
-  cache: Record<string, T>;
-  updatePromise?: Promise<void> | undefined;
-}
-
-interface JenkinsPluginInfo {
-  name: string;
-  scm?: string;
-}
-
-interface JenkinsPluginVersion {
-  version: string;
-  buildDate?: string;
-  url?: string;
-}
-
-interface JenkinsPluginsInfoResponse {
-  plugins: Record<string, JenkinsPluginInfo>;
-}
-
-interface JenkinsPluginsVersionsResponse {
-  plugins: Record<string, Record<string, JenkinsPluginVersion>>;
-}
-
 function hasCacheExpired(cache: JenkinsCache<JenkinsCacheTypes>): boolean {
   return getElapsedMinutes(cache.lastSync) >= cache.cacheTimeMin;
 }
diff --git a/lib/datasource/jenkins-plugins/types.ts b/lib/datasource/jenkins-plugins/types.ts
new file mode 100644
index 0000000000..6c67a9bca1
--- /dev/null
+++ b/lib/datasource/jenkins-plugins/types.ts
@@ -0,0 +1,31 @@
+import type { Release, ReleaseResult } from '../types';
+
+export type JenkinsCacheTypes = ReleaseResult | Release[];
+
+export interface JenkinsCache<T> {
+  name: string;
+  dataUrl: string;
+  lastSync: Date;
+  cacheTimeMin: number;
+  cache: Record<string, T>;
+  updatePromise?: Promise<void> | undefined;
+}
+
+export interface JenkinsPluginInfo {
+  name: string;
+  scm?: string;
+}
+
+export interface JenkinsPluginVersion {
+  version: string;
+  buildDate?: string;
+  url?: string;
+}
+
+export interface JenkinsPluginsInfoResponse {
+  plugins: Record<string, JenkinsPluginInfo>;
+}
+
+export interface JenkinsPluginsVersionsResponse {
+  plugins: Record<string, Record<string, JenkinsPluginVersion>>;
+}
diff --git a/lib/datasource/npm/get.ts b/lib/datasource/npm/get.ts
index 2dada2be0f..cfbb1764e4 100644
--- a/lib/datasource/npm/get.ts
+++ b/lib/datasource/npm/get.ts
@@ -4,10 +4,9 @@ import { logger } from '../../logger';
 import { ExternalHostError } from '../../types/errors/external-host-error';
 import * as packageCache from '../../util/cache/package';
 import { Http, HttpOptions } from '../../util/http';
-import type { Release, ReleaseResult } from '../types';
 import { id } from './common';
 import { resolvePackage } from './npmrc';
-import { NpmResponse } from './types';
+import type { NpmDependency, NpmRelease, NpmResponse } from './types';
 
 const http = new Http(id);
 
@@ -22,20 +21,6 @@ export function resetCache(): void {
   resetMemCache();
 }
 
-export interface NpmRelease extends Release {
-  gitRef?: string;
-}
-export interface NpmDependency extends ReleaseResult {
-  releases: NpmRelease[];
-  deprecationSource?: string;
-  name: string;
-  homepage: string;
-  sourceUrl: string;
-  versions: Record<string, any>;
-  'dist-tags': Record<string, string>;
-  sourceDirectory?: string;
-}
-
 export async function getDependency(
   packageName: string
 ): Promise<NpmDependency | null> {
diff --git a/lib/datasource/npm/npmrc.ts b/lib/datasource/npm/npmrc.ts
index ccfa73de07..832d2080e7 100644
--- a/lib/datasource/npm/npmrc.ts
+++ b/lib/datasource/npm/npmrc.ts
@@ -8,12 +8,11 @@ import { logger } from '../../logger';
 import type { OutgoingHttpHeaders } from '../../util/http/types';
 import { maskToken } from '../../util/mask';
 import { add } from '../../util/sanitize';
+import type { Npmrc, PackageResolution } from './types';
 
 let npmrc: Record<string, any> = {};
 let npmrcRaw = '';
 
-export type Npmrc = Record<string, any>;
-
 export function getNpmrc(): Npmrc | null {
   return npmrc;
 }
@@ -94,12 +93,6 @@ export function setNpmrc(input?: string): void {
   }
 }
 
-export interface PackageResolution {
-  headers: OutgoingHttpHeaders;
-  packageUrl: string;
-  registryUrl: string;
-}
-
 export function resolvePackage(packageName: string): PackageResolution {
   const scope = packageName.split('/')[0];
   let registryUrl: string;
diff --git a/lib/datasource/npm/types.ts b/lib/datasource/npm/types.ts
index fccba01f86..aa4ff75f9a 100644
--- a/lib/datasource/npm/types.ts
+++ b/lib/datasource/npm/types.ts
@@ -1,3 +1,6 @@
+import type { OutgoingHttpHeaders } from '../../util/http/types';
+import type { Release, ReleaseResult } from '../types';
+
 export interface NpmResponse {
   _id: string;
   name?: string;
@@ -22,3 +25,25 @@ export interface NpmResponse {
   homepage?: string;
   time?: Record<string, string>;
 }
+
+export interface NpmRelease extends Release {
+  gitRef?: string;
+}
+export interface NpmDependency extends ReleaseResult {
+  releases: NpmRelease[];
+  deprecationSource?: string;
+  name: string;
+  homepage: string;
+  sourceUrl: string;
+  versions: Record<string, any>;
+  'dist-tags': Record<string, string>;
+  sourceDirectory?: string;
+}
+
+export type Npmrc = Record<string, any>;
+
+export interface PackageResolution {
+  headers: OutgoingHttpHeaders;
+  packageUrl: string;
+  registryUrl: string;
+}
diff --git a/lib/datasource/nuget/types.ts b/lib/datasource/nuget/types.ts
new file mode 100644
index 0000000000..d8a4d9815d
--- /dev/null
+++ b/lib/datasource/nuget/types.ts
@@ -0,0 +1,24 @@
+export interface ServicesIndexRaw {
+  resources: {
+    '@id': string;
+    '@type': string;
+  }[];
+}
+
+export interface CatalogEntry {
+  version: string;
+  published?: string;
+  projectUrl?: string;
+  listed?: boolean;
+}
+
+export interface CatalogPage {
+  '@id': string;
+  items: {
+    catalogEntry: CatalogEntry;
+  }[];
+}
+
+export interface PackageRegistration {
+  items: CatalogPage[];
+}
diff --git a/lib/datasource/nuget/v2.ts b/lib/datasource/nuget/v2.ts
index a7c7ed1285..4a4e03e97d 100644
--- a/lib/datasource/nuget/v2.ts
+++ b/lib/datasource/nuget/v2.ts
@@ -2,7 +2,6 @@ import { XmlDocument, XmlElement } from 'xmldoc';
 import { logger } from '../../logger';
 import { Http } from '../../util/http';
 import type { ReleaseResult } from '../types';
-
 import { id, removeBuildMeta } from './common';
 
 const http = new Http(id);
diff --git a/lib/datasource/nuget/v3.ts b/lib/datasource/nuget/v3.ts
index a7ee70a76d..364318bd8e 100644
--- a/lib/datasource/nuget/v3.ts
+++ b/lib/datasource/nuget/v3.ts
@@ -1,15 +1,20 @@
 import is from '@sindresorhus/is';
-import { RequestError } from 'got';
 import pAll from 'p-all';
 import * as semver from 'semver';
 import { XmlDocument } from 'xmldoc';
 import { logger } from '../../logger';
 import * as packageCache from '../../util/cache/package';
 import { Http } from '../../util/http';
+import { HttpError } from '../../util/http/types';
 import { ensureTrailingSlash } from '../../util/url';
 import type { Release, ReleaseResult } from '../types';
-
 import { id, removeBuildMeta } from './common';
+import type {
+  CatalogEntry,
+  CatalogPage,
+  PackageRegistration,
+  ServicesIndexRaw,
+} from './types';
 
 const http = new Http(id);
 
@@ -21,13 +26,6 @@ export function getDefaultFeed(): string {
   return defaultNugetFeed;
 }
 
-interface ServicesIndexRaw {
-  resources: {
-    '@id': string;
-    '@type': string;
-  }[];
-}
-
 export async function getResourceUrl(
   url: string,
   resourceType = 'RegistrationsBaseUrl'
@@ -96,24 +94,6 @@ export async function getResourceUrl(
   }
 }
 
-interface CatalogEntry {
-  version: string;
-  published?: string;
-  projectUrl?: string;
-  listed?: boolean;
-}
-
-interface CatalogPage {
-  '@id': string;
-  items: {
-    catalogEntry: CatalogEntry;
-  }[];
-}
-
-interface PackageRegistration {
-  items: CatalogPage[];
-}
-
 async function getCatalogEntry(
   catalogPage: CatalogPage
 ): Promise<CatalogEntry[]> {
@@ -195,7 +175,7 @@ export async function getReleases(
     }
   } catch (err) /* istanbul ignore next */ {
     // ignore / silence 404. Seen on proget, if remote connector is used and package is not yet cached
-    if (err instanceof RequestError && err.response?.statusCode === 404) {
+    if (err instanceof HttpError && err.response?.statusCode === 404) {
       logger.debug(
         { registryUrl, pkgName, pkgVersion: latestStable },
         `package manifest (.nuspec) not found`
diff --git a/lib/datasource/orb/index.ts b/lib/datasource/orb/index.ts
index 546167c187..46bd773857 100644
--- a/lib/datasource/orb/index.ts
+++ b/lib/datasource/orb/index.ts
@@ -2,6 +2,7 @@ import { logger } from '../../logger';
 import * as packageCache from '../../util/cache/package';
 import { Http } from '../../util/http';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { OrbRelease } from './types';
 
 export const id = 'orb';
 export const defaultRegistryUrls = ['https://circleci.com/'];
@@ -9,14 +10,6 @@ export const customRegistrySupport = false;
 
 const http = new Http(id);
 
-interface OrbRelease {
-  homeUrl?: string;
-  versions: {
-    version: string;
-    createdAt?: string;
-  }[];
-}
-
 /**
  * orb.getReleases
  *
diff --git a/lib/datasource/orb/types.ts b/lib/datasource/orb/types.ts
new file mode 100644
index 0000000000..a1f1941c27
--- /dev/null
+++ b/lib/datasource/orb/types.ts
@@ -0,0 +1,7 @@
+export interface OrbRelease {
+  homeUrl?: string;
+  versions: {
+    version: string;
+    createdAt?: string;
+  }[];
+}
diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts
index 78dc632ab3..75f0c5611c 100644
--- a/lib/datasource/packagist/index.ts
+++ b/lib/datasource/packagist/index.ts
@@ -1,5 +1,4 @@
 import URL from 'url';
-
 import pAll from 'p-all';
 import { logger } from '../../logger';
 import { ExternalHostError } from '../../types/errors/external-host-error';
@@ -9,6 +8,13 @@ import * as hostRules from '../../util/host-rules';
 import { Http, HttpOptions } from '../../util/http';
 import * as composerVersioning from '../../versioning/composer';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type {
+  AllPackages,
+  PackageMeta,
+  PackagistFile,
+  RegistryFile,
+  RegistryMeta,
+} from './types';
 
 export const id = 'packagist';
 export const customRegistrySupport = true;
@@ -31,27 +37,6 @@ function getHostOpts(url: string): HttpOptions {
   return opts;
 }
 
-interface PackageMeta {
-  includes?: Record<string, { sha256: string }>;
-  packages: Record<string, RegistryFile>;
-  'provider-includes': Record<string, { sha256: string }>;
-  providers: Record<string, { sha256: string }>;
-  'providers-url'?: string;
-}
-
-interface RegistryFile {
-  key: string;
-  sha256: string;
-}
-interface RegistryMeta {
-  files?: RegistryFile[];
-  providerPackages: Record<string, string>;
-  providersUrl?: string;
-  providersLazyUrl?: string;
-  includesFiles?: RegistryFile[];
-  packages?: Record<string, RegistryFile>;
-}
-
 async function getRegistryMeta(regUrl: string): Promise<RegistryMeta | null> {
   const url = URL.resolve(regUrl.replace(/\/?$/, '/'), 'packages.json');
   const opts = getHostOpts(url);
@@ -94,11 +79,6 @@ async function getRegistryMeta(regUrl: string): Promise<RegistryMeta | null> {
   return meta;
 }
 
-interface PackagistFile {
-  providers: Record<string, RegistryFile>;
-  packages?: Record<string, RegistryFile>;
-}
-
 async function getPackagistFile(
   regUrl: string,
   file: RegistryFile
@@ -152,15 +132,6 @@ function extractDepReleases(versions: RegistryFile): ReleaseResult {
   return dep;
 }
 
-interface AllPackages {
-  packages: Record<string, RegistryFile>;
-  providersUrl: string;
-  providersLazyUrl: string;
-  providerPackages: Record<string, string>;
-
-  includesPackages: Record<string, ReleaseResult>;
-}
-
 async function getAllPackages(regUrl: string): Promise<AllPackages | null> {
   const registryMeta = await getRegistryMeta(regUrl);
   const {
diff --git a/lib/datasource/packagist/types.ts b/lib/datasource/packagist/types.ts
new file mode 100644
index 0000000000..5422b0839c
--- /dev/null
+++ b/lib/datasource/packagist/types.ts
@@ -0,0 +1,35 @@
+import type { ReleaseResult } from '../types';
+
+export interface PackageMeta {
+  includes?: Record<string, { sha256: string }>;
+  packages: Record<string, RegistryFile>;
+  'provider-includes': Record<string, { sha256: string }>;
+  providers: Record<string, { sha256: string }>;
+  'providers-url'?: string;
+}
+export interface RegistryFile {
+  key: string;
+  sha256: string;
+}
+export interface RegistryMeta {
+  files?: RegistryFile[];
+  providerPackages: Record<string, string>;
+  providersUrl?: string;
+  providersLazyUrl?: string;
+  includesFiles?: RegistryFile[];
+  packages?: Record<string, RegistryFile>;
+}
+
+export interface PackagistFile {
+  providers: Record<string, RegistryFile>;
+  packages?: Record<string, RegistryFile>;
+}
+
+export interface AllPackages {
+  packages: Record<string, RegistryFile>;
+  providersUrl: string;
+  providersLazyUrl: string;
+  providerPackages: Record<string, string>;
+
+  includesPackages: Record<string, ReleaseResult>;
+}
diff --git a/lib/datasource/repology/index.spec.ts b/lib/datasource/repology/index.spec.ts
index e84d7e092a..3e61a3675e 100644
--- a/lib/datasource/repology/index.spec.ts
+++ b/lib/datasource/repology/index.spec.ts
@@ -3,7 +3,8 @@ import * as httpMock from '../../../test/http-mock';
 import { getName, loadFixture } from '../../../test/util';
 import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
 import { id as versioning } from '../../versioning/loose';
-import { RepologyPackage, id as datasource } from '.';
+import type { RepologyPackage } from './types';
+import { id as datasource } from '.';
 
 const repologyHost = 'https://repology.org/';
 
diff --git a/lib/datasource/repology/index.ts b/lib/datasource/repology/index.ts
index 4551ac596b..fd571da101 100644
--- a/lib/datasource/repology/index.ts
+++ b/lib/datasource/repology/index.ts
@@ -5,6 +5,7 @@ import * as packageCache from '../../util/cache/package';
 import { Http } from '../../util/http';
 import { getQueryString } from '../../util/url';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { RepologyPackage, RepologyPackageType } from './types';
 
 export const id = 'repology';
 export const customRegistrySupport = true;
@@ -15,18 +16,8 @@ const http = new Http(id);
 const cacheNamespace = `datasource-${id}-list`;
 const cacheMinutes = 60;
 
-export type RepologyPackageType = 'binname' | 'srcname';
 const packageTypes: RepologyPackageType[] = ['binname', 'srcname'];
 
-export interface RepologyPackage {
-  repo: string;
-  visiblename: string;
-  version: string;
-  srcname?: string;
-  binname?: string;
-  origversion?: string;
-}
-
 async function queryPackages(url: string): Promise<RepologyPackage[]> {
   try {
     const res = await http.getJson<RepologyPackage[]>(url);
@@ -101,7 +92,7 @@ function findPackageInResponse(
   // In some cases Repology bundles multiple packages into a single project, which might result in ambiguous results.
   // We need to do additional filtering by matching allowed package types passed as params with package description.
   // Remaining packages are the one we are looking for
-  let packagesWithType;
+  let packagesWithType: RepologyPackage[];
   for (const pkgType of types) {
     packagesWithType = repoPackages.filter(
       (pkg) => !pkg[pkgType] || pkg[pkgType] === pkgName
diff --git a/lib/datasource/repology/types.ts b/lib/datasource/repology/types.ts
new file mode 100644
index 0000000000..7d1f9f39b6
--- /dev/null
+++ b/lib/datasource/repology/types.ts
@@ -0,0 +1,10 @@
+export interface RepologyPackage {
+  repo: string;
+  visiblename: string;
+  version: string;
+  srcname?: string;
+  binname?: string;
+  origversion?: string;
+}
+
+export type RepologyPackageType = 'binname' | 'srcname';
diff --git a/lib/datasource/terraform-module/index.ts b/lib/datasource/terraform-module/index.ts
index 57fb1f4b9e..42c165da21 100644
--- a/lib/datasource/terraform-module/index.ts
+++ b/lib/datasource/terraform-module/index.ts
@@ -4,6 +4,11 @@ import * as packageCache from '../../util/cache/package';
 import { Http } from '../../util/http';
 import * as hashicorpVersioning from '../../versioning/hashicorp';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type {
+  RegistryRepository,
+  ServiceDiscoveryResult,
+  TerraformRelease,
+} from './types';
 
 export const id = 'terraform-module';
 export const customRegistrySupport = true;
@@ -13,11 +18,6 @@ export const registryStrategy = 'first';
 
 const http = new Http(id);
 
-interface RegistryRepository {
-  registry: string;
-  repository: string;
-}
-
 function getRegistryRepository(
   lookupName: string,
   registryUrl: string
@@ -40,21 +40,6 @@ function getRegistryRepository(
   };
 }
 
-interface TerraformRelease {
-  namespace: string;
-  name: string;
-  provider: string;
-  source?: string;
-  versions: string[];
-  version: string;
-  published_at: string;
-}
-
-export interface ServiceDiscoveryResult {
-  'modules.v1'?: string;
-  'providers.v1'?: string;
-}
-
 export async function getTerraformServiceDiscoveryResult(
   registryUrl: string
 ): Promise<ServiceDiscoveryResult> {
diff --git a/lib/datasource/terraform-module/types.ts b/lib/datasource/terraform-module/types.ts
new file mode 100644
index 0000000000..1bdcb62598
--- /dev/null
+++ b/lib/datasource/terraform-module/types.ts
@@ -0,0 +1,19 @@
+export interface RegistryRepository {
+  registry: string;
+  repository: string;
+}
+
+export interface TerraformRelease {
+  namespace: string;
+  name: string;
+  provider: string;
+  source?: string;
+  versions: string[];
+  version: string;
+  published_at: string;
+}
+
+export interface ServiceDiscoveryResult {
+  'modules.v1'?: string;
+  'providers.v1'?: string;
+}
diff --git a/lib/datasource/terraform-provider/index.ts b/lib/datasource/terraform-provider/index.ts
index e1894928f5..10986fedbc 100644
--- a/lib/datasource/terraform-provider/index.ts
+++ b/lib/datasource/terraform-provider/index.ts
@@ -5,6 +5,10 @@ import { Http } from '../../util/http';
 import * as hashicorpVersioning from '../../versioning/hashicorp';
 import { getTerraformServiceDiscoveryResult } from '../terraform-module';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type {
+  TerraformProvider,
+  TerraformProviderReleaseBackend,
+} from './types';
 
 export const id = 'terraform-provider';
 export const customRegistrySupport = true;
@@ -17,27 +21,6 @@ export const registryStrategy = 'hunt';
 
 const http = new Http(id);
 
-interface TerraformProvider {
-  namespace: string;
-  name: string;
-  provider: string;
-  source?: string;
-  versions: string[];
-  version: string;
-  published_at: string;
-}
-
-interface TerraformProviderReleaseBackend {
-  [key: string]: {
-    name: string;
-    versions: VersionsReleaseBackend;
-  };
-}
-
-interface VersionsReleaseBackend {
-  [key: string]: Record<string, any>;
-}
-
 async function queryRegistry(
   lookupName: string,
   registryURL: string,
diff --git a/lib/datasource/terraform-provider/types.ts b/lib/datasource/terraform-provider/types.ts
new file mode 100644
index 0000000000..40f3bdfadc
--- /dev/null
+++ b/lib/datasource/terraform-provider/types.ts
@@ -0,0 +1,20 @@
+export interface TerraformProvider {
+  namespace: string;
+  name: string;
+  provider: string;
+  source?: string;
+  versions: string[];
+  version: string;
+  published_at: string;
+}
+
+export interface TerraformProviderReleaseBackend {
+  [key: string]: {
+    name: string;
+    versions: VersionsReleaseBackend;
+  };
+}
+
+interface VersionsReleaseBackend {
+  [key: string]: Record<string, any>;
+}
diff --git a/lib/logger/index.ts b/lib/logger/index.ts
index b8884663de..ee082b6a18 100644
--- a/lib/logger/index.ts
+++ b/lib/logger/index.ts
@@ -1,22 +1,16 @@
 import is from '@sindresorhus/is';
 import * as bunyan from 'bunyan';
 import * as shortid from 'shortid';
-
 import cmdSerializer from './cmd-serializer';
 import configSerializer from './config-serializer';
 import errSerializer from './err-serializer';
 import { RenovateStream } from './pretty-stdout';
-import { BunyanRecord, ProblemStream, withSanitizer } from './utils';
+import type { BunyanRecord, Logger } from './types';
+import { ProblemStream, withSanitizer } from './utils';
 
 let logContext: string = process.env.LOG_CONTEXT || shortid.generate();
 let curMeta = {};
 
-export interface LogError {
-  level: bunyan.LogLevel;
-  meta: any;
-  msg?: string;
-}
-
 const problems = new ProblemStream();
 
 const stdout: bunyan.Stream = {
@@ -85,21 +79,6 @@ const loggerLevels: bunyan.LogLevelString[] = [
   'fatal',
 ];
 
-interface Logger {
-  trace(msg: string): void;
-  trace(meta: Record<string, any>, msg?: string): void;
-  debug(msg: string): void;
-  debug(meta: Record<string, any>, msg?: string): void;
-  info(msg: string): void;
-  info(meta: Record<string, any>, msg?: string): void;
-  warn(msg: string): void;
-  warn(meta: Record<string, any>, msg?: string): void;
-  error(msg: string): void;
-  error(meta: Record<string, any>, msg?: string): void;
-  fatal(msg: string): void;
-  fatal(meta: Record<string, any>, msg?: string): void;
-}
-
 export const logger: Logger = {} as any;
 
 loggerLevels.forEach((loggerLevel) => {
diff --git a/lib/logger/pretty-stdout.spec.ts b/lib/logger/pretty-stdout.spec.ts
index fa43f80d1f..895ae6c7c6 100644
--- a/lib/logger/pretty-stdout.spec.ts
+++ b/lib/logger/pretty-stdout.spec.ts
@@ -1,7 +1,7 @@
 import chalk from 'chalk';
 import { getName } from '../../test/util';
 import * as prettyStdout from './pretty-stdout';
-import type { BunyanRecord } from './utils';
+import type { BunyanRecord } from './types';
 
 jest.mock('chalk', () =>
   ['bgRed', 'blue', 'gray', 'green', 'magenta', 'red'].reduce(
diff --git a/lib/logger/pretty-stdout.ts b/lib/logger/pretty-stdout.ts
index c74d9173b4..df7b6a0921 100644
--- a/lib/logger/pretty-stdout.ts
+++ b/lib/logger/pretty-stdout.ts
@@ -5,7 +5,7 @@ import { Stream } from 'stream';
 import * as util from 'util';
 import chalk from 'chalk';
 import stringify from 'json-stringify-pretty-compact';
-import type { BunyanRecord } from './utils';
+import type { BunyanRecord } from './types';
 
 const bunyanFields = [
   'name',
diff --git a/lib/logger/types.ts b/lib/logger/types.ts
new file mode 100644
index 0000000000..a7d081e0a2
--- /dev/null
+++ b/lib/logger/types.ts
@@ -0,0 +1,34 @@
+import type { Stream } from 'stream';
+import type { LogLevel } from 'bunyan';
+
+export interface LogError {
+  level: LogLevel;
+  meta: any;
+  msg?: string;
+}
+
+export interface Logger {
+  trace(msg: string): void;
+  trace(meta: Record<string, any>, msg?: string): void;
+  debug(msg: string): void;
+  debug(meta: Record<string, any>, msg?: string): void;
+  info(msg: string): void;
+  info(meta: Record<string, any>, msg?: string): void;
+  warn(msg: string): void;
+  warn(meta: Record<string, any>, msg?: string): void;
+  error(msg: string): void;
+  error(meta: Record<string, any>, msg?: string): void;
+  fatal(msg: string): void;
+  fatal(meta: Record<string, any>, msg?: string): void;
+}
+
+export interface BunyanRecord extends Record<string, any> {
+  level: number;
+  msg: string;
+  module?: string;
+}
+
+export type BunyanStream = (NodeJS.WritableStream | Stream) & {
+  writable?: boolean;
+  write: (chunk: BunyanRecord, enc, cb) => void;
+};
diff --git a/lib/logger/utils.ts b/lib/logger/utils.ts
index 77f77e73ca..36945b4eed 100644
--- a/lib/logger/utils.ts
+++ b/lib/logger/utils.ts
@@ -1,15 +1,10 @@
 import { Stream } from 'stream';
 import bunyan from 'bunyan';
 import fs from 'fs-extra';
-import { RequestError } from 'got';
 import { clone } from '../util/clone';
+import { HttpError } from '../util/http/types';
 import { redactedFields, sanitize } from '../util/sanitize';
-
-export interface BunyanRecord extends Record<string, any> {
-  level: number;
-  msg: string;
-  module?: string;
-}
+import type { BunyanRecord, BunyanStream } from './types';
 
 const excludeProps = ['pid', 'time', 'v', 'hostname'];
 
@@ -67,7 +62,7 @@ export default function prepareError(err: Error): Record<string, unknown> {
   }
 
   // handle got error
-  if (err instanceof RequestError) {
+  if (err instanceof HttpError) {
     const options: Record<string, unknown> = {
       headers: clone(err.options.headers),
       url: err.options.url?.toString(),
@@ -152,11 +147,6 @@ export function sanitizeValue(value: unknown, seen = new WeakMap()): any {
   return valueType === 'string' ? sanitize(value as string) : value;
 }
 
-type BunyanStream = (NodeJS.WritableStream | Stream) & {
-  writable?: boolean;
-  write: (chunk: BunyanRecord, enc, cb) => void;
-};
-
 export function withSanitizer(streamConfig: bunyan.Stream): bunyan.Stream {
   if (streamConfig.type === 'rotating-file') {
     throw new Error("Rotating files aren't supported");
diff --git a/lib/util/cache/package/index.ts b/lib/util/cache/package/index.ts
index e0b65e6312..d1d5655b30 100644
--- a/lib/util/cache/package/index.ts
+++ b/lib/util/cache/package/index.ts
@@ -1,8 +1,8 @@
 import type { GlobalConfig } from '../../../config/types';
 import * as memCache from '../memory';
-import type { PackageCache } from './common';
 import * as fileCache from './file';
 import * as redisCache from './redis';
+import type { PackageCache } from './types';
 
 let cacheProxy: PackageCache;
 
diff --git a/lib/util/cache/package/common.ts b/lib/util/cache/package/types.ts
similarity index 100%
rename from lib/util/cache/package/common.ts
rename to lib/util/cache/package/types.ts
diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts
index 58fb957469..4c540193a3 100644
--- a/lib/util/cache/repository/index.ts
+++ b/lib/util/cache/repository/index.ts
@@ -6,7 +6,7 @@ import type {
 } from '../../../config/types';
 import { logger } from '../../../logger';
 import type { PackageFile } from '../../../manager/types';
-import type { RepoInitConfig } from '../../../workers/repository/init/common';
+import type { RepoInitConfig } from '../../../workers/repository/init/types';
 
 // Increment this whenever there could be incompatibilities between old and new cache structure
 export const CACHE_REVISION = 8;
diff --git a/lib/workers/repository/init/merge.ts b/lib/workers/repository/init/merge.ts
index 012c454d5f..3571fcc648 100644
--- a/lib/workers/repository/init/merge.ts
+++ b/lib/workers/repository/init/merge.ts
@@ -18,7 +18,7 @@ import { logger } from '../../../logger';
 import { readLocalFile } from '../../../util/fs';
 import { getFileList } from '../../../util/git';
 import * as hostRules from '../../../util/host-rules';
-import { RepoFileConfig } from './common';
+import type { RepoFileConfig } from './types';
 
 export async function detectRepoFileConfig(): Promise<RepoFileConfig> {
   const fileList = await getFileList();
diff --git a/lib/workers/repository/init/common.ts b/lib/workers/repository/init/types.ts
similarity index 100%
rename from lib/workers/repository/init/common.ts
rename to lib/workers/repository/init/types.ts
-- 
GitLab