From 9ca604b3453ca55795bd10d3fcad4475c3c8c7cb Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Tue, 11 May 2021 19:08:02 +0200
Subject: [PATCH] refactor: extract more types (#9959)

---
 lib/config/presets/types.ts                 | 14 +++++
 lib/config/presets/util.spec.ts             |  9 +--
 lib/config/presets/util.ts                  | 16 +----
 lib/datasource/github-releases/index.ts     |  7 +--
 lib/datasource/github-releases/types.ts     |  5 ++
 lib/datasource/gitlab-tags/index.ts         |  9 +--
 lib/datasource/gitlab-tags/types.ts         |  6 ++
 lib/datasource/maven/index.ts               | 10 +--
 lib/datasource/maven/types.ts               |  4 ++
 lib/datasource/pypi/index.ts                | 17 +-----
 lib/datasource/pypi/types.ts                | 15 +++++
 lib/manager/azure-pipelines/extract.ts      | 20 +-----
 lib/manager/azure-pipelines/types.ts        | 15 +++++
 lib/manager/batect/extract.ts               |  7 +--
 lib/manager/batect/types.ts                 |  7 +++
 lib/manager/bazel/extract.ts                |  7 +--
 lib/manager/bazel/types.ts                  |  5 ++
 lib/manager/cocoapods/extract.ts            | 13 +---
 lib/manager/cocoapods/types.ts              | 11 ++++
 lib/manager/composer/artifacts.ts           | 13 +---
 lib/manager/composer/range.ts               |  2 +-
 lib/manager/composer/types.ts               | 12 ++++
 lib/manager/docker-compose/extract.ts       | 16 +----
 lib/manager/docker-compose/types.ts         | 12 ++++
 lib/manager/git-submodules/extract.ts       |  6 +-
 lib/manager/git-submodules/types.ts         |  4 ++
 lib/manager/gradle-lite/common.ts           | 56 +----------------
 lib/manager/gradle-lite/extract.ts          |  2 +-
 lib/manager/gradle-lite/parser.ts           | 25 ++------
 lib/manager/gradle-lite/tokenizer.ts        |  3 +-
 lib/manager/gradle-lite/types.ts            | 67 +++++++++++++++++++++
 lib/manager/gradle-lite/update.ts           |  2 +-
 lib/manager/gradle-lite/utils.ts            |  4 +-
 lib/manager/gradle/build-gradle.ts          | 16 +----
 lib/manager/gradle/gradle-updates-report.ts | 27 ++-------
 lib/manager/gradle/index.ts                 |  2 +-
 lib/manager/gradle/types.ts                 | 29 +++++++++
 lib/manager/helm-values/extract.ts          |  7 +--
 lib/manager/helm-values/types.ts            |  5 ++
 lib/manager/helm-values/util.ts             |  7 +--
 lib/manager/helmfile/extract.ts             | 12 +---
 lib/manager/helmfile/types.ts               | 10 +++
 lib/manager/homebrew/extract.ts             |  7 +--
 lib/manager/homebrew/types.ts               |  5 ++
 lib/manager/kustomize/extract.ts            | 13 +---
 lib/manager/kustomize/types.ts              | 10 +++
 lib/manager/leiningen/extract.ts            |  6 +-
 lib/manager/leiningen/types.ts              |  4 ++
 lib/manager/maven/extract.ts                |  7 +--
 lib/manager/maven/types.ts                  |  5 ++
 lib/manager/npm/post-update/index.ts        | 31 +++-------
 lib/manager/npm/post-update/lerna.ts        |  6 +-
 lib/manager/npm/post-update/npm.ts          |  7 +--
 lib/manager/npm/post-update/pnpm.ts         |  8 +--
 lib/manager/npm/post-update/types.ts        | 34 +++++++++++
 lib/manager/npm/post-update/yarn.ts         |  7 +--
 lib/manager/nuget/types.ts                  |  5 ++
 lib/manager/nuget/util.ts                   |  6 +-
 lib/manager/pip_setup/extract.ts            |  3 +-
 lib/manager/pip_setup/types.ts              |  4 ++
 lib/manager/pip_setup/util.ts               |  6 +-
 lib/manager/pipenv/artifacts.spec.ts        |  2 +-
 lib/manager/pipenv/extract.ts               | 22 +------
 lib/manager/pipenv/types.ts                 | 20 ++++++
 lib/manager/sbt/extract.ts                  | 13 +---
 lib/manager/sbt/types.ts                    | 11 ++++
 lib/manager/swift/extract.ts                |  8 +--
 lib/manager/swift/types.ts                  |  6 ++
 lib/manager/terraform/common.ts             | 28 +++++++++
 lib/manager/terraform/extract.ts            |  4 +-
 lib/manager/terraform/modules.ts            |  3 +-
 lib/manager/terraform/providers.ts          |  8 +--
 lib/manager/terraform/required-providers.ts |  8 +--
 lib/manager/terraform/required-version.ts   |  8 +--
 lib/manager/terraform/resources.ts          |  6 +-
 lib/manager/terraform/types.ts              | 22 +++++++
 lib/manager/terraform/util.spec.ts          |  3 +-
 lib/manager/terraform/util.ts               | 48 +--------------
 lib/manager/terragrunt/common.ts            |  8 +++
 lib/manager/terragrunt/extract.ts           |  4 +-
 lib/manager/terragrunt/modules.ts           |  3 +-
 lib/manager/terragrunt/providers.ts         |  8 +--
 lib/manager/terragrunt/types.ts             | 22 +++++++
 lib/manager/terragrunt/util.spec.ts         |  3 +-
 lib/manager/terragrunt/util.ts              | 31 +---------
 lib/util/cache/repository/index.ts          | 41 +------------
 lib/util/cache/repository/types.ts          | 40 ++++++++++++
 lib/workers/branch/index.spec.ts            |  2 +-
 lib/workers/repository/cache.ts             |  6 +-
 89 files changed, 546 insertions(+), 552 deletions(-)
 create mode 100644 lib/datasource/github-releases/types.ts
 create mode 100644 lib/datasource/gitlab-tags/types.ts
 create mode 100644 lib/datasource/pypi/types.ts
 create mode 100644 lib/manager/azure-pipelines/types.ts
 create mode 100644 lib/manager/bazel/types.ts
 create mode 100644 lib/manager/cocoapods/types.ts
 create mode 100644 lib/manager/docker-compose/types.ts
 create mode 100644 lib/manager/git-submodules/types.ts
 create mode 100644 lib/manager/gradle-lite/types.ts
 create mode 100644 lib/manager/gradle/types.ts
 create mode 100644 lib/manager/helm-values/types.ts
 create mode 100644 lib/manager/helmfile/types.ts
 create mode 100644 lib/manager/homebrew/types.ts
 create mode 100644 lib/manager/kustomize/types.ts
 create mode 100644 lib/manager/leiningen/types.ts
 create mode 100644 lib/manager/maven/types.ts
 create mode 100644 lib/manager/npm/post-update/types.ts
 create mode 100644 lib/manager/pip_setup/types.ts
 create mode 100644 lib/manager/pipenv/types.ts
 create mode 100644 lib/manager/sbt/types.ts
 create mode 100644 lib/manager/swift/types.ts
 create mode 100644 lib/manager/terraform/common.ts
 create mode 100644 lib/manager/terraform/types.ts
 create mode 100644 lib/manager/terragrunt/common.ts
 create mode 100644 lib/manager/terragrunt/types.ts
 create mode 100644 lib/util/cache/repository/types.ts

diff --git a/lib/config/presets/types.ts b/lib/config/presets/types.ts
index 329f933e65..4833c59b5c 100644
--- a/lib/config/presets/types.ts
+++ b/lib/config/presets/types.ts
@@ -21,3 +21,17 @@ export interface ParsedPreset {
   presetName: string;
   params?: string[];
 }
+
+export type PresetFetcher = (
+  repo: string,
+  fileName: string,
+  endpoint: string
+) => Promise<Preset>;
+
+export type FetchPresetConfig = {
+  pkgName: string;
+  filePreset: string;
+  presetPath?: string;
+  endpoint: string;
+  fetch: PresetFetcher;
+};
diff --git a/lib/config/presets/util.spec.ts b/lib/config/presets/util.spec.ts
index a4a9ff908a..752dc8fff6 100644
--- a/lib/config/presets/util.spec.ts
+++ b/lib/config/presets/util.spec.ts
@@ -1,11 +1,6 @@
 import { getName } from '../../../test/util';
-import type { Preset } from './types';
-import {
-  FetchPresetConfig,
-  PRESET_DEP_NOT_FOUND,
-  PRESET_NOT_FOUND,
-  fetchPreset,
-} from './util';
+import type { FetchPresetConfig, Preset } from './types';
+import { PRESET_DEP_NOT_FOUND, PRESET_NOT_FOUND, fetchPreset } from './util';
 
 const config: FetchPresetConfig = {
   pkgName: 'some/repo',
diff --git a/lib/config/presets/util.ts b/lib/config/presets/util.ts
index 6d224a8c15..f14573cc37 100644
--- a/lib/config/presets/util.ts
+++ b/lib/config/presets/util.ts
@@ -1,6 +1,6 @@
 import { logger } from '../../logger';
 import { ensureTrailingSlash } from '../../util/url';
-import type { Preset } from './types';
+import type { FetchPresetConfig, Preset } from './types';
 
 export const PRESET_DEP_NOT_FOUND = 'dep not found';
 export const PRESET_INVALID = 'invalid preset';
@@ -10,20 +10,6 @@ export const PRESET_PROHIBITED_SUBPRESET = 'prohibited sub-preset';
 export const PRESET_RENOVATE_CONFIG_NOT_FOUND =
   'preset renovate-config not found';
 
-export type PresetFetcher = (
-  repo: string,
-  fileName: string,
-  endpoint: string
-) => Promise<Preset>;
-
-export type FetchPresetConfig = {
-  pkgName: string;
-  filePreset: string;
-  presetPath?: string;
-  endpoint: string;
-  fetch: PresetFetcher;
-};
-
 export async function fetchPreset({
   pkgName,
   filePreset,
diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts
index a505dd7424..4fe6e5469e 100644
--- a/lib/datasource/github-releases/index.ts
+++ b/lib/datasource/github-releases/index.ts
@@ -2,6 +2,7 @@ import * as packageCache from '../../util/cache/package';
 import { GithubHttp } from '../../util/http/github';
 import { ensureTrailingSlash } from '../../util/url';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { GithubRelease } from './types';
 
 export const id = 'github-releases';
 export const customRegistrySupport = true;
@@ -17,12 +18,6 @@ function getCacheKey(depHost: string, repo: string): string {
   return `${depHost}:${repo}:${type}`;
 }
 
-type GithubRelease = {
-  tag_name: string;
-  published_at: string;
-  prerelease: boolean;
-};
-
 /**
  * github.getReleases
  *
diff --git a/lib/datasource/github-releases/types.ts b/lib/datasource/github-releases/types.ts
new file mode 100644
index 0000000000..48ca80461e
--- /dev/null
+++ b/lib/datasource/github-releases/types.ts
@@ -0,0 +1,5 @@
+export type GithubRelease = {
+  tag_name: string;
+  published_at: string;
+  prerelease: boolean;
+};
diff --git a/lib/datasource/gitlab-tags/index.ts b/lib/datasource/gitlab-tags/index.ts
index bb9c0f3c95..6c93462dc3 100644
--- a/lib/datasource/gitlab-tags/index.ts
+++ b/lib/datasource/gitlab-tags/index.ts
@@ -2,6 +2,7 @@ import URL from 'url';
 import * as packageCache from '../../util/cache/package';
 import { GitlabHttp } from '../../util/http/gitlab';
 import type { GetReleasesConfig, ReleaseResult } from '../types';
+import type { GitlabTag } from './types';
 
 const gitlabApi = new GitlabHttp();
 
@@ -11,18 +12,12 @@ export const defaultRegistryUrls = ['https://gitlab.com'];
 export const registryStrategy = 'first';
 
 const cacheNamespace = 'datasource-gitlab';
+
 function getCacheKey(depHost: string, repo: string): string {
   const type = 'tags';
   return `${depHost}:${repo}:${type}`;
 }
 
-type GitlabTag = {
-  name: string;
-  commit?: {
-    created_at?: string;
-  };
-};
-
 export async function getReleases({
   registryUrl: depHost,
   lookupName: repo,
diff --git a/lib/datasource/gitlab-tags/types.ts b/lib/datasource/gitlab-tags/types.ts
new file mode 100644
index 0000000000..47d6ee66bd
--- /dev/null
+++ b/lib/datasource/gitlab-tags/types.ts
@@ -0,0 +1,6 @@
+export type GitlabTag = {
+  name: string;
+  commit?: {
+    created_at?: string;
+  };
+};
diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts
index 8ee4e527b4..21b4bb26ac 100644
--- a/lib/datasource/maven/index.ts
+++ b/lib/datasource/maven/index.ts
@@ -8,7 +8,11 @@ import * as mavenVersioning from '../../versioning/maven';
 import { compare } from '../../versioning/maven/compare';
 import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
 import { MAVEN_REPO } from './common';
-import type { MavenDependency } from './types';
+import type {
+  ArtifactInfoResult,
+  ArtifactsInfo,
+  MavenDependency,
+} from './types';
 import {
   downloadMavenXml,
   getDependencyInfo,
@@ -80,8 +84,6 @@ async function getVersionsFromMetadata(
   return versions;
 }
 
-type ArtifactsInfo = Record<string, boolean | null>;
-
 // istanbul ignore next
 function isValidArtifactsInfo(
   info: ArtifactsInfo | null,
@@ -93,8 +95,6 @@ function isValidArtifactsInfo(
   return versions.every((v) => info[v] !== undefined);
 }
 
-type ArtifactInfoResult = [string, boolean | string | null];
-
 async function getArtifactInfo(
   version: string,
   artifactUrl: url.URL
diff --git a/lib/datasource/maven/types.ts b/lib/datasource/maven/types.ts
index 06d8fd4c21..2d314a4078 100644
--- a/lib/datasource/maven/types.ts
+++ b/lib/datasource/maven/types.ts
@@ -11,3 +11,7 @@ export interface MavenXml {
   authorization?: boolean;
   xml?: XmlDocument;
 }
+
+export type ArtifactsInfo = Record<string, boolean | null>;
+
+export type ArtifactInfoResult = [string, boolean | string | null];
diff --git a/lib/datasource/pypi/index.ts b/lib/datasource/pypi/index.ts
index 144e417ec8..f68d0afe26 100644
--- a/lib/datasource/pypi/index.ts
+++ b/lib/datasource/pypi/index.ts
@@ -6,6 +6,7 @@ import { Http } from '../../util/http';
 import { ensureTrailingSlash } from '../../util/url';
 import * as pep440 from '../../versioning/pep440';
 import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
+import type { PypiJSON, PypiJSONRelease, Releases } from './types';
 
 export const id = 'pypi';
 export const customRegistrySupport = true;
@@ -19,22 +20,6 @@ export const caching = true;
 const githubRepoPattern = /^https?:\/\/github\.com\/[^\\/]+\/[^\\/]+$/;
 const http = new Http(id);
 
-type PypiJSONRelease = {
-  requires_python?: string;
-  upload_time?: string;
-  yanked?: boolean;
-};
-type Releases = Record<string, PypiJSONRelease[]>;
-type PypiJSON = {
-  info: {
-    name: string;
-    home_page?: string;
-    project_urls?: Record<string, string>;
-  };
-
-  releases?: Releases;
-};
-
 function normalizeName(input: string): string {
   return input.toLowerCase().replace(/(-|\.)/g, '_');
 }
diff --git a/lib/datasource/pypi/types.ts b/lib/datasource/pypi/types.ts
new file mode 100644
index 0000000000..b63ec776cd
--- /dev/null
+++ b/lib/datasource/pypi/types.ts
@@ -0,0 +1,15 @@
+export type PypiJSONRelease = {
+  requires_python?: string;
+  upload_time?: string;
+  yanked?: boolean;
+};
+export type Releases = Record<string, PypiJSONRelease[]>;
+export type PypiJSON = {
+  info: {
+    name: string;
+    home_page?: string;
+    project_urls?: Record<string, string>;
+  };
+
+  releases?: Releases;
+};
diff --git a/lib/manager/azure-pipelines/extract.ts b/lib/manager/azure-pipelines/extract.ts
index 06b946b365..8307542e9d 100644
--- a/lib/manager/azure-pipelines/extract.ts
+++ b/lib/manager/azure-pipelines/extract.ts
@@ -3,25 +3,7 @@ import * as datasourceGitTags from '../../datasource/git-tags';
 import { logger } from '../../logger';
 import { getDep } from '../dockerfile/extract';
 import type { PackageDependency, PackageFile } from '../types';
-
-interface Container {
-  image: string;
-}
-
-interface Repository {
-  type: 'git' | 'github' | 'bitbucket';
-  name: string;
-  ref: string;
-}
-
-interface Resources {
-  repositories: Repository[];
-  containers: Container[];
-}
-
-interface AzurePipelines {
-  resources: Resources;
-}
+import type { AzurePipelines, Container, Repository } from './types';
 
 export function extractRepository(
   repository: Repository
diff --git a/lib/manager/azure-pipelines/types.ts b/lib/manager/azure-pipelines/types.ts
new file mode 100644
index 0000000000..708638e200
--- /dev/null
+++ b/lib/manager/azure-pipelines/types.ts
@@ -0,0 +1,15 @@
+export interface Container {
+  image: string;
+}
+export interface Repository {
+  type: 'git' | 'github' | 'bitbucket';
+  name: string;
+  ref: string;
+}
+export interface Resources {
+  repositories: Repository[];
+  containers: Container[];
+}
+export interface AzurePipelines {
+  resources: Resources;
+}
diff --git a/lib/manager/batect/extract.ts b/lib/manager/batect/extract.ts
index c75c05b10d..1062361f69 100644
--- a/lib/manager/batect/extract.ts
+++ b/lib/manager/batect/extract.ts
@@ -1,6 +1,5 @@
 import { safeLoad } from 'js-yaml';
 import * as upath from 'upath';
-
 import { id as gitTagDatasource } from '../../datasource/git-tags';
 import { logger } from '../../logger';
 import { readLocalFile } from '../../util/fs';
@@ -13,6 +12,7 @@ import type {
   BatectFileInclude,
   BatectGitInclude,
   BatectInclude,
+  ExtractionResult,
 } from './types';
 
 function loadConfig(content: string): BatectConfig {
@@ -116,11 +116,6 @@ function extractReferencedConfigFiles(
   return paths.map((p) => upath.join(dirName, p));
 }
 
-interface ExtractionResult {
-  deps: PackageDependency[];
-  referencedConfigFiles: string[];
-}
-
 export function extractPackageFile(
   content: string,
   fileName: string
diff --git a/lib/manager/batect/types.ts b/lib/manager/batect/types.ts
index 0495bbe86b..c5a1765e70 100644
--- a/lib/manager/batect/types.ts
+++ b/lib/manager/batect/types.ts
@@ -1,3 +1,5 @@
+import type { PackageDependency } from '../types';
+
 export interface BatectConfig {
   containers?: Record<string, BatectContainer>;
   include?: BatectInclude[];
@@ -19,3 +21,8 @@ export interface BatectGitInclude {
   repo: string;
   ref: string;
 }
+
+export interface ExtractionResult {
+  deps: PackageDependency[];
+  referencedConfigFiles: string[];
+}
diff --git a/lib/manager/bazel/extract.ts b/lib/manager/bazel/extract.ts
index 197e801b66..2c2d534fef 100644
--- a/lib/manager/bazel/extract.ts
+++ b/lib/manager/bazel/extract.ts
@@ -10,12 +10,7 @@ import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import * as dockerVersioning from '../../versioning/docker';
 import type { PackageDependency, PackageFile } from '../types';
-
-interface UrlParsedResult {
-  datasource: string;
-  repo: string;
-  currentValue: string;
-}
+import type { UrlParsedResult } from './types';
 
 function parseUrl(urlString: string): UrlParsedResult | null {
   // istanbul ignore if
diff --git a/lib/manager/bazel/types.ts b/lib/manager/bazel/types.ts
new file mode 100644
index 0000000000..78960463e5
--- /dev/null
+++ b/lib/manager/bazel/types.ts
@@ -0,0 +1,5 @@
+export interface UrlParsedResult {
+  datasource: string;
+  repo: string;
+  currentValue: string;
+}
diff --git a/lib/manager/cocoapods/extract.ts b/lib/manager/cocoapods/extract.ts
index c6f88feba6..1f15a83065 100644
--- a/lib/manager/cocoapods/extract.ts
+++ b/lib/manager/cocoapods/extract.ts
@@ -4,6 +4,7 @@ import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import { getSiblingFileName, localPathExists } from '../../util/fs';
 import type { PackageDependency, PackageFile } from '../types';
+import type { ParsedLine } from './types';
 
 const regexMappings = [
   /^\s*pod\s+(['"])(?<spec>[^'"/]+)(\/(?<subspec>[^'"]+))?\1/,
@@ -14,18 +15,6 @@ const regexMappings = [
   /^\s*source\s*(['"])(?<source>[^'"]+)\1/,
 ];
 
-export interface ParsedLine {
-  depName?: string;
-  groupName?: string;
-  spec?: string;
-  subspec?: string;
-  currentValue?: string;
-  git?: string;
-  tag?: string;
-  path?: string;
-  source?: string;
-}
-
 export function parseLine(line: string): ParsedLine {
   let result: ParsedLine = {};
   if (!line) {
diff --git a/lib/manager/cocoapods/types.ts b/lib/manager/cocoapods/types.ts
new file mode 100644
index 0000000000..74fef13b82
--- /dev/null
+++ b/lib/manager/cocoapods/types.ts
@@ -0,0 +1,11 @@
+export interface ParsedLine {
+  depName?: string;
+  groupName?: string;
+  spec?: string;
+  subspec?: string;
+  currentValue?: string;
+  git?: string;
+  tag?: string;
+  path?: string;
+  source?: string;
+}
diff --git a/lib/manager/composer/artifacts.ts b/lib/manager/composer/artifacts.ts
index 229c629cbf..eee7d89949 100644
--- a/lib/manager/composer/artifacts.ts
+++ b/lib/manager/composer/artifacts.ts
@@ -25,20 +25,9 @@ import {
 import { getRepoStatus } from '../../util/git';
 import * as hostRules from '../../util/host-rules';
 import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
+import type { AuthJson } from './types';
 import { composerVersioningId, getConstraint } from './utils';
 
-interface UserPass {
-  username: string;
-  password: string;
-}
-
-interface AuthJson {
-  'github-oauth'?: Record<string, string>;
-  'gitlab-token'?: Record<string, string>;
-  'gitlab-domains'?: string[];
-  'http-basic'?: Record<string, UserPass>;
-}
-
 function getAuthJson(): string | null {
   const authJson: AuthJson = {};
 
diff --git a/lib/manager/composer/range.ts b/lib/manager/composer/range.ts
index 65212e27cd..325578e66a 100644
--- a/lib/manager/composer/range.ts
+++ b/lib/manager/composer/range.ts
@@ -1,7 +1,7 @@
 import { logger } from '../../logger';
 import type { RangeStrategy } from '../../types';
 import type { RangeConfig } from '../types';
-import { ComposerManagerData } from './types';
+import type { ComposerManagerData } from './types';
 
 export function getRangeStrategy(config: RangeConfig): RangeStrategy {
   const {
diff --git a/lib/manager/composer/types.ts b/lib/manager/composer/types.ts
index 2b421f7edc..3e34fe8604 100644
--- a/lib/manager/composer/types.ts
+++ b/lib/manager/composer/types.ts
@@ -34,3 +34,15 @@ export interface ComposerLock {
 export interface ComposerManagerData {
   composerJsonType?: string;
 }
+
+export interface UserPass {
+  username: string;
+  password: string;
+}
+
+export interface AuthJson {
+  'github-oauth'?: Record<string, string>;
+  'gitlab-token'?: Record<string, string>;
+  'gitlab-domains'?: string[];
+  'http-basic'?: Record<string, UserPass>;
+}
diff --git a/lib/manager/docker-compose/extract.ts b/lib/manager/docker-compose/extract.ts
index 43be4a262a..7e276b0db5 100644
--- a/lib/manager/docker-compose/extract.ts
+++ b/lib/manager/docker-compose/extract.ts
@@ -3,19 +3,7 @@ import { safeLoad } from 'js-yaml';
 import { logger } from '../../logger';
 import { getDep } from '../dockerfile/extract';
 import type { PackageFile } from '../types';
-
-interface DockerComposeConfig {
-  version?: string;
-  services?: Record<string, DockerComposeService>;
-}
-
-interface DockerComposeService {
-  image?: string;
-  build?: {
-    context?: string;
-    dockerfile?: string;
-  };
-}
+import type { DockerComposeConfig } from './types';
 
 class LineMapper {
   private imageLines: { line: string; lineNumber: number; used: boolean }[];
@@ -47,7 +35,7 @@ export function extractPackageFile(
   let config: DockerComposeConfig;
   try {
     // TODO: fix me (#9610)
-    config = safeLoad(content, { json: true }) as unknown;
+    config = safeLoad(content, { json: true }) as DockerComposeConfig;
     if (!config) {
       logger.debug(
         { fileName },
diff --git a/lib/manager/docker-compose/types.ts b/lib/manager/docker-compose/types.ts
new file mode 100644
index 0000000000..25495d8062
--- /dev/null
+++ b/lib/manager/docker-compose/types.ts
@@ -0,0 +1,12 @@
+export type DockerComposeConfig = {
+  version?: string;
+  services?: Record<string, DockerComposeService>;
+} & Record<string, DockerComposeService>;
+
+export interface DockerComposeService {
+  image?: string;
+  build?: {
+    context?: string;
+    dockerfile?: string;
+  };
+}
diff --git a/lib/manager/git-submodules/extract.ts b/lib/manager/git-submodules/extract.ts
index 50e3e667c6..ac41b7f6b7 100644
--- a/lib/manager/git-submodules/extract.ts
+++ b/lib/manager/git-submodules/extract.ts
@@ -5,11 +5,7 @@ import * as datasourceGitRefs from '../../datasource/git-refs';
 import { logger } from '../../logger';
 import { getHttpUrl, getRemoteUrlWithToken } from '../../util/git/url';
 import type { ManagerConfig, PackageFile } from '../types';
-
-type GitModule = {
-  name: string;
-  path: string;
-};
+import { GitModule } from './types';
 
 async function getUrl(
   git: SimpleGit,
diff --git a/lib/manager/git-submodules/types.ts b/lib/manager/git-submodules/types.ts
new file mode 100644
index 0000000000..24fb38a15a
--- /dev/null
+++ b/lib/manager/git-submodules/types.ts
@@ -0,0 +1,4 @@
+export type GitModule = {
+  name: string;
+  path: string;
+};
diff --git a/lib/manager/gradle-lite/common.ts b/lib/manager/gradle-lite/common.ts
index 3ef9d3c020..5cf3d4dac2 100644
--- a/lib/manager/gradle-lite/common.ts
+++ b/lib/manager/gradle-lite/common.ts
@@ -1,23 +1,9 @@
-import type { PackageDependency } from '../types';
-
 export { MAVEN_REPO } from '../../datasource/maven/common';
 
 export const JCENTER_REPO = 'https://jcenter.bintray.com/';
 export const GOOGLE_REPO = 'https://dl.google.com/android/maven2/';
 
-export interface ManagerData {
-  fileReplacePosition: number;
-  packageFile?: string;
-}
-
-export interface VariableData extends ManagerData {
-  key: string;
-  value: string;
-}
-
-export type PackageVariables = Record<string, VariableData>;
-export type VariableRegistry = Record<string, PackageVariables>;
-
+// TODO: convert to types
 export enum TokenType {
   Space = 'space',
   LineComment = 'lineComment',
@@ -62,43 +48,3 @@ export enum TokenType {
 
   UnknownFragment = 'unknownFragment',
 }
-
-export interface Token {
-  type: TokenType;
-  value: string;
-  offset: number;
-}
-
-export interface StringInterpolation extends Token {
-  type: TokenType.StringInterpolation;
-  children: Token[]; // Tokens inside double-quoted string that are subject of interpolation
-  isComplete: boolean; // True if token has parsed completely
-  isValid: boolean; // False if string contains something unprocessable
-}
-
-// Matcher on single token
-export interface SyntaxMatcher {
-  matchType: TokenType | TokenType[];
-  matchValue?: string | string[];
-  lookahead?: boolean;
-  tokenMapKey?: string;
-}
-
-export type TokenMap = Record<string, Token>;
-
-export interface SyntaxHandlerInput {
-  packageFile: string;
-  variables: PackageVariables;
-  tokenMap: TokenMap;
-}
-
-export type SyntaxHandlerOutput = {
-  deps?: PackageDependency<ManagerData>[];
-  vars?: PackageVariables;
-  urls?: string[];
-} | null;
-
-export interface SyntaxMatchConfig {
-  matchers: SyntaxMatcher[];
-  handler: (MatcherHandlerInput) => SyntaxHandlerOutput;
-}
diff --git a/lib/manager/gradle-lite/extract.ts b/lib/manager/gradle-lite/extract.ts
index 80c5db748b..d6a8fe9aeb 100644
--- a/lib/manager/gradle-lite/extract.ts
+++ b/lib/manager/gradle-lite/extract.ts
@@ -3,8 +3,8 @@ import { id as datasource, defaultRegistryUrls } from '../../datasource/maven';
 import { logger } from '../../logger';
 import { readLocalFile } from '../../util/fs';
 import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
-import type { ManagerData, PackageVariables, VariableRegistry } from './common';
 import { parseGradle, parseProps } from './parser';
+import type { ManagerData, PackageVariables, VariableRegistry } from './types';
 import {
   getVars,
   isGradleFile,
diff --git a/lib/manager/gradle-lite/parser.ts b/lib/manager/gradle-lite/parser.ts
index 5827c9de08..f20432155e 100644
--- a/lib/manager/gradle-lite/parser.ts
+++ b/lib/manager/gradle-lite/parser.ts
@@ -3,12 +3,13 @@ import is from '@sindresorhus/is';
 import { logger } from '../../logger';
 import { regEx } from '../../util/regex';
 import type { PackageDependency } from '../types';
-import {
-  GOOGLE_REPO,
-  JCENTER_REPO,
-  MAVEN_REPO,
+import { GOOGLE_REPO, JCENTER_REPO, MAVEN_REPO, TokenType } from './common';
+import { tokenize } from './tokenizer';
+import type {
   ManagerData,
+  MatchConfig,
   PackageVariables,
+  ParseGradleResult,
   StringInterpolation,
   SyntaxHandlerInput,
   SyntaxHandlerOutput,
@@ -16,10 +17,8 @@ import {
   SyntaxMatcher,
   Token,
   TokenMap,
-  TokenType,
   VariableData,
-} from './common';
-import { tokenize } from './tokenizer';
+} from './types';
 import {
   interpolateString,
   isDependencyString,
@@ -487,12 +486,6 @@ const matcherConfigs: SyntaxMatchConfig[] = [
   },
 ];
 
-interface MatchConfig {
-  tokens: Token[];
-  variables: PackageVariables;
-  packageFile: string;
-}
-
 function tryMatch({
   tokens,
   variables,
@@ -515,12 +508,6 @@ function tryMatch({
   return null;
 }
 
-interface ParseGradleResult {
-  deps: PackageDependency<ManagerData>[];
-  urls: string[];
-  vars: PackageVariables;
-}
-
 export function parseGradle(
   input: string,
   initVars: PackageVariables = {},
diff --git a/lib/manager/gradle-lite/tokenizer.ts b/lib/manager/gradle-lite/tokenizer.ts
index 0025b268d6..e966326855 100644
--- a/lib/manager/gradle-lite/tokenizer.ts
+++ b/lib/manager/gradle-lite/tokenizer.ts
@@ -1,5 +1,6 @@
 import moo from 'moo';
-import { StringInterpolation, Token, TokenType } from './common';
+import { TokenType } from './common';
+import { StringInterpolation, Token } from './types';
 
 const escapedCharRegex = /\\['"bfnrt\\]/;
 const escapedChars = {
diff --git a/lib/manager/gradle-lite/types.ts b/lib/manager/gradle-lite/types.ts
new file mode 100644
index 0000000000..10f1d0c374
--- /dev/null
+++ b/lib/manager/gradle-lite/types.ts
@@ -0,0 +1,67 @@
+import type { PackageDependency } from '../types';
+import type { TokenType } from './common';
+
+export interface ManagerData {
+  fileReplacePosition: number;
+  packageFile?: string;
+}
+
+export interface VariableData extends ManagerData {
+  key: string;
+  value: string;
+}
+
+export type PackageVariables = Record<string, VariableData>;
+export type VariableRegistry = Record<string, PackageVariables>;
+
+export interface Token {
+  type: TokenType;
+  value: string;
+  offset: number;
+}
+
+export interface StringInterpolation extends Token {
+  type: TokenType.StringInterpolation;
+  children: Token[]; // Tokens inside double-quoted string that are subject of interpolation
+  isComplete: boolean; // True if token has parsed completely
+  isValid: boolean; // False if string contains something unprocessable
+}
+
+// Matcher on single token
+export interface SyntaxMatcher {
+  matchType: TokenType | TokenType[];
+  matchValue?: string | string[];
+  lookahead?: boolean;
+  tokenMapKey?: string;
+}
+
+export type TokenMap = Record<string, Token>;
+
+export interface SyntaxHandlerInput {
+  packageFile: string;
+  variables: PackageVariables;
+  tokenMap: TokenMap;
+}
+
+export type SyntaxHandlerOutput = {
+  deps?: PackageDependency<ManagerData>[];
+  vars?: PackageVariables;
+  urls?: string[];
+} | null;
+
+export interface SyntaxMatchConfig {
+  matchers: SyntaxMatcher[];
+  handler: (MatcherHandlerInput) => SyntaxHandlerOutput;
+}
+
+export interface MatchConfig {
+  tokens: Token[];
+  variables: PackageVariables;
+  packageFile: string;
+}
+
+export interface ParseGradleResult {
+  deps: PackageDependency<ManagerData>[];
+  urls: string[];
+  vars: PackageVariables;
+}
diff --git a/lib/manager/gradle-lite/update.ts b/lib/manager/gradle-lite/update.ts
index 2666cf3c62..2de06c6117 100644
--- a/lib/manager/gradle-lite/update.ts
+++ b/lib/manager/gradle-lite/update.ts
@@ -1,6 +1,6 @@
 import { logger } from '../../logger';
 import type { UpdateDependencyConfig } from '../types';
-import type { ManagerData } from './common';
+import type { ManagerData } from './types';
 import { versionLikeSubstring } from './utils';
 
 export function updateDependency({
diff --git a/lib/manager/gradle-lite/utils.ts b/lib/manager/gradle-lite/utils.ts
index 639725795a..85fc366270 100644
--- a/lib/manager/gradle-lite/utils.ts
+++ b/lib/manager/gradle-lite/utils.ts
@@ -1,13 +1,13 @@
 import upath from 'upath';
 import { regEx } from '../../util/regex';
 import type { PackageDependency } from '../types';
+import { TokenType } from './common';
 import {
   ManagerData,
   PackageVariables,
   Token,
-  TokenType,
   VariableRegistry,
-} from './common';
+} from './types';
 
 const artifactRegex = regEx(
   '^[a-zA-Z][-_a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-_a-zA-Z0-9]*?)*$'
diff --git a/lib/manager/gradle/build-gradle.ts b/lib/manager/gradle/build-gradle.ts
index a142433632..e90b245e2f 100644
--- a/lib/manager/gradle/build-gradle.ts
+++ b/lib/manager/gradle/build-gradle.ts
@@ -1,5 +1,5 @@
 import { regEx } from '../../util/regex';
-import { BuildDependency } from './gradle-updates-report';
+import { BuildDependency, GradleDependency, UpdateFunction } from './types';
 
 /**
  * Functions adapted/ported from https://github.com/patrikerdes/gradle-use-latest-versions-plugin
@@ -8,20 +8,6 @@ import { BuildDependency } from './gradle-updates-report';
 
 let variables: Record<string, string> = {};
 
-export interface GradleDependency {
-  group: string;
-  name: string;
-  version?: string;
-}
-
-interface UpdateFunction {
-  (
-    dependency: GradleDependency,
-    buildGradleContent: string,
-    newValue: string
-  ): string;
-}
-
 const groovyQuotes = `(?:["'](?:""|'')?)`;
 const groovyVersionVariable = `(?:${groovyQuotes}\\$)?{?([^\\s"'{}$)]+)}?${groovyQuotes}?`;
 const kotlinVersionVariable = `(?:"\\$)?{?([^\\s"{}$]+?)}?"?`;
diff --git a/lib/manager/gradle/gradle-updates-report.ts b/lib/manager/gradle/gradle-updates-report.ts
index 1398fb99a4..e90ca89600 100644
--- a/lib/manager/gradle/gradle-updates-report.ts
+++ b/lib/manager/gradle/gradle-updates-report.ts
@@ -2,31 +2,14 @@ import { exists, readFile, writeFile } from 'fs-extra';
 import { join } from 'upath';
 import * as datasourceSbtPackage from '../../datasource/sbt-package';
 import { logger } from '../../logger';
+import type {
+  BuildDependency,
+  GradleDependencyWithRepos,
+  GradleProject,
+} from './types';
 
 export const GRADLE_DEPENDENCY_REPORT_FILENAME = 'gradle-renovate-report.json';
 
-interface GradleProject {
-  project: string;
-  repositories: string[];
-  dependencies: GradleDependency[];
-}
-
-interface GradleDependency {
-  name: string;
-  group: string;
-  version: string;
-}
-
-type GradleDependencyWithRepos = GradleDependency & { repos: string[] };
-
-export interface BuildDependency {
-  name: string;
-  depGroup: string;
-  depName?: string;
-  currentValue?: string;
-  registryUrls?: string[];
-}
-
 export async function createRenovateGradlePlugin(
   localDir: string
 ): Promise<void> {
diff --git a/lib/manager/gradle/index.ts b/lib/manager/gradle/index.ts
index 04550342bc..c83bf3d783 100644
--- a/lib/manager/gradle/index.ts
+++ b/lib/manager/gradle/index.ts
@@ -16,7 +16,6 @@ import type {
   Upgrade,
 } from '../types';
 import {
-  GradleDependency,
   collectVersionVariables,
   init,
   updateGradleVersion,
@@ -25,6 +24,7 @@ import {
   createRenovateGradlePlugin,
   extractDependenciesFromUpdatesReport,
 } from './gradle-updates-report';
+import type { GradleDependency } from './types';
 import { extraEnv, gradleWrapperFileName, prepareGradleCommand } from './utils';
 
 export const GRADLE_DEPENDENCY_REPORT_OPTIONS =
diff --git a/lib/manager/gradle/types.ts b/lib/manager/gradle/types.ts
new file mode 100644
index 0000000000..00994f1429
--- /dev/null
+++ b/lib/manager/gradle/types.ts
@@ -0,0 +1,29 @@
+export interface GradleDependency {
+  group: string;
+  name: string;
+  version?: string;
+}
+
+export interface UpdateFunction {
+  (
+    dependency: GradleDependency,
+    buildGradleContent: string,
+    newValue: string
+  ): string;
+}
+
+export interface GradleProject {
+  project: string;
+  repositories: string[];
+  dependencies: GradleDependency[];
+}
+
+export type GradleDependencyWithRepos = GradleDependency & { repos: string[] };
+
+export interface BuildDependency {
+  name: string;
+  depGroup: string;
+  depName?: string;
+  currentValue?: string;
+  registryUrls?: string[];
+}
diff --git a/lib/manager/helm-values/extract.ts b/lib/manager/helm-values/extract.ts
index f2cd4230c0..6ee1da6bea 100644
--- a/lib/manager/helm-values/extract.ts
+++ b/lib/manager/helm-values/extract.ts
@@ -3,11 +3,8 @@ import { logger } from '../../logger';
 import { id as dockerVersioning } from '../../versioning/docker';
 import { getDep } from '../dockerfile/extract';
 import type { PackageDependency, PackageFile } from '../types';
-
-import {
-  HelmDockerImageDependency,
-  matchesHelmValuesDockerHeuristic,
-} from './util';
+import type { HelmDockerImageDependency } from './types';
+import { matchesHelmValuesDockerHeuristic } from './util';
 
 function getHelmDep({
   registry,
diff --git a/lib/manager/helm-values/types.ts b/lib/manager/helm-values/types.ts
new file mode 100644
index 0000000000..b507048353
--- /dev/null
+++ b/lib/manager/helm-values/types.ts
@@ -0,0 +1,5 @@
+export type HelmDockerImageDependency = {
+  registry?: string;
+  repository: string;
+  tag: string;
+};
diff --git a/lib/manager/helm-values/util.ts b/lib/manager/helm-values/util.ts
index 1aeabaf30b..ffc9ee74cb 100644
--- a/lib/manager/helm-values/util.ts
+++ b/lib/manager/helm-values/util.ts
@@ -1,10 +1,5 @@
 import { hasKey } from '../../util/object';
-
-export type HelmDockerImageDependency = {
-  registry?: string;
-  repository: string;
-  tag: string;
-};
+import { HelmDockerImageDependency } from './types';
 
 const parentKeyRe = /image$/i;
 
diff --git a/lib/manager/helmfile/extract.ts b/lib/manager/helmfile/extract.ts
index 5273622ba3..72d7bda798 100644
--- a/lib/manager/helmfile/extract.ts
+++ b/lib/manager/helmfile/extract.ts
@@ -4,21 +4,11 @@ import * as datasourceHelm from '../../datasource/helm';
 import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
+import type { Doc } from './types';
 
 const isValidChartName = (name: string): boolean =>
   !/[!@#$%^&*(),.?":{}/|<>A-Z]/.test(name);
 
-interface Doc {
-  releases?: {
-    chart: string;
-    version: string;
-  }[];
-  repositories?: {
-    name: string;
-    url: string;
-  }[];
-}
-
 export function extractPackageFile(
   content: string,
   fileName: string,
diff --git a/lib/manager/helmfile/types.ts b/lib/manager/helmfile/types.ts
new file mode 100644
index 0000000000..8c6b6a19bb
--- /dev/null
+++ b/lib/manager/helmfile/types.ts
@@ -0,0 +1,10 @@
+export interface Doc {
+  releases?: {
+    chart: string;
+    version: string;
+  }[];
+  repositories?: {
+    name: string;
+    url: string;
+  }[];
+}
diff --git a/lib/manager/homebrew/extract.ts b/lib/manager/homebrew/extract.ts
index c6d34398e1..04803fc6c5 100644
--- a/lib/manager/homebrew/extract.ts
+++ b/lib/manager/homebrew/extract.ts
@@ -2,6 +2,7 @@ import * as datasourceGithubTags from '../../datasource/github-tags';
 import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import type { PackageDependency, PackageFile } from '../types';
+import type { UrlPathParsedResult } from './types';
 import { isSpace, removeComments, skip } from './util';
 
 function parseSha256(idx: number, content: string): string | null {
@@ -54,12 +55,6 @@ function extractUrl(content: string): string | null {
   return parseUrl(i, content);
 }
 
-export interface UrlPathParsedResult {
-  currentValue: string;
-  ownerName: string;
-  repoName: string;
-}
-
 export function parseUrlPath(urlStr: string): UrlPathParsedResult | null {
   if (!urlStr) {
     return null;
diff --git a/lib/manager/homebrew/types.ts b/lib/manager/homebrew/types.ts
new file mode 100644
index 0000000000..723eacfef2
--- /dev/null
+++ b/lib/manager/homebrew/types.ts
@@ -0,0 +1,5 @@
+export interface UrlPathParsedResult {
+  currentValue: string;
+  ownerName: string;
+  repoName: string;
+}
diff --git a/lib/manager/kustomize/extract.ts b/lib/manager/kustomize/extract.ts
index cb1b70580f..5fe464ebc3 100644
--- a/lib/manager/kustomize/extract.ts
+++ b/lib/manager/kustomize/extract.ts
@@ -5,18 +5,7 @@ import * as datasourceGitHubTags from '../../datasource/github-tags';
 import { logger } from '../../logger';
 import * as dockerVersioning from '../../versioning/docker';
 import type { PackageDependency, PackageFile } from '../types';
-
-interface Image {
-  name: string;
-  newTag: string;
-  newName?: string;
-}
-
-interface Kustomize {
-  kind: string;
-  bases: string[];
-  images: Image[];
-}
+import type { Image, Kustomize } from './types';
 
 // URL specifications should follow the hashicorp URL format
 // https://github.com/hashicorp/go-getter#url-format
diff --git a/lib/manager/kustomize/types.ts b/lib/manager/kustomize/types.ts
new file mode 100644
index 0000000000..b791575c30
--- /dev/null
+++ b/lib/manager/kustomize/types.ts
@@ -0,0 +1,10 @@
+export interface Image {
+  name: string;
+  newTag: string;
+  newName?: string;
+}
+export interface Kustomize {
+  kind: string;
+  bases: string[];
+  images: Image[];
+}
diff --git a/lib/manager/leiningen/extract.ts b/lib/manager/leiningen/extract.ts
index 360c4ce3d9..ea712618cf 100644
--- a/lib/manager/leiningen/extract.ts
+++ b/lib/manager/leiningen/extract.ts
@@ -1,5 +1,6 @@
 import * as datasourceClojure from '../../datasource/clojure';
 import type { PackageDependency, PackageFile } from '../types';
+import type { ExtractContext } from './types';
 
 export function trimAtKey(str: string, kwName: string): string | null {
   const regex = new RegExp(`:${kwName}(?=\\s)`);
@@ -19,11 +20,6 @@ export function expandDepName(name: string): string {
   return name.includes('/') ? name.replace('/', ':') : `${name}:${name}`;
 }
 
-export interface ExtractContext {
-  depType?: string;
-  registryUrls?: string[];
-}
-
 export function extractFromVectors(
   str: string,
   offset = 0,
diff --git a/lib/manager/leiningen/types.ts b/lib/manager/leiningen/types.ts
new file mode 100644
index 0000000000..940f428932
--- /dev/null
+++ b/lib/manager/leiningen/types.ts
@@ -0,0 +1,4 @@
+export interface ExtractContext {
+  depType?: string;
+  registryUrls?: string[];
+}
diff --git a/lib/manager/maven/extract.ts b/lib/manager/maven/extract.ts
index 8c725a77a9..a8721584c6 100644
--- a/lib/manager/maven/extract.ts
+++ b/lib/manager/maven/extract.ts
@@ -7,6 +7,7 @@ import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import { readLocalFile } from '../../util/fs';
 import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
+import type { MavenProp } from './types';
 
 export function parsePom(raw: string): XmlDocument | null {
   let project: XmlDocument;
@@ -35,12 +36,6 @@ function containsPlaceholder(str: string): boolean {
   return /\${.*?}/g.test(str);
 }
 
-interface MavenProp {
-  val: string;
-  fileReplacePosition: number;
-  packageFile: string;
-}
-
 function depFromNode(node: XmlElement): PackageDependency | null {
   if (!('valueWithPath' in node)) {
     return null;
diff --git a/lib/manager/maven/types.ts b/lib/manager/maven/types.ts
new file mode 100644
index 0000000000..af4354e8da
--- /dev/null
+++ b/lib/manager/maven/types.ts
@@ -0,0 +1,5 @@
+export interface MavenProp {
+  val: string;
+  fileReplacePosition: number;
+  packageFile: string;
+}
diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts
index a9e9f70b36..8de797b7e2 100644
--- a/lib/manager/npm/post-update/index.ts
+++ b/lib/manager/npm/post-update/index.ts
@@ -23,6 +23,13 @@ import type { PackageFile, PostUpdateConfig, Upgrade } from '../../types';
 import * as lerna from './lerna';
 import * as npm from './npm';
 import * as pnpm from './pnpm';
+import type {
+  AdditionalPackageFiles,
+  ArtifactError,
+  DetermineLockFileDirsResult,
+  UpdatedArtifacts,
+  WriteExistingFilesResult,
+} from './types';
 import * as yarn from './yarn';
 
 // Strips empty values, deduplicates, and returns the directories from filenames
@@ -30,12 +37,6 @@ import * as yarn from './yarn';
 const getDirs = (arr: string[]): string[] =>
   Array.from(new Set(arr.filter(Boolean)));
 
-export interface DetermineLockFileDirsResult {
-  yarnLockDirs: string[];
-  npmLockDirs: string[];
-  pnpmShrinkwrapDirs: string[];
-  lernaJsonFiles: string[];
-}
 // istanbul ignore next
 export function determineLockFileDirs(
   config: PostUpdateConfig,
@@ -263,20 +264,6 @@ export async function writeUpdatedPackageFiles(
   }
 }
 
-export interface AdditionalPackageFiles {
-  npm?: Partial<PackageFile>[];
-}
-
-interface ArtifactError {
-  lockFile: string;
-  stderr: string;
-}
-
-interface UpdatedArtifacts {
-  name: string;
-  contents: string | Buffer;
-}
-
 // istanbul ignore next
 async function getNpmrcContent(dir: string): Promise<string | null> {
   const npmrcFilePath = upath.join(dir, '.npmrc');
@@ -398,10 +385,6 @@ async function updateYarnOffline(
   }
 }
 
-export interface WriteExistingFilesResult {
-  artifactErrors: ArtifactError[];
-  updatedArtifacts: UpdatedArtifacts[];
-}
 // istanbul ignore next
 export async function getAdditionalFiles(
   config: PostUpdateConfig,
diff --git a/lib/manager/npm/post-update/lerna.ts b/lib/manager/npm/post-update/lerna.ts
index 4cf0bc5475..94f661afc0 100644
--- a/lib/manager/npm/post-update/lerna.ts
+++ b/lib/manager/npm/post-update/lerna.ts
@@ -6,13 +6,9 @@ import { logger } from '../../../logger';
 import { ExecOptions, exec } from '../../../util/exec';
 import type { PackageFile, PostUpdateConfig } from '../../types';
 import { getNodeConstraint } from './node-version';
+import type { GenerateLockFileResult } from './types';
 import { getOptimizeCommand } from './yarn';
 
-export interface GenerateLockFileResult {
-  error?: boolean;
-  stderr?: string;
-}
-
 // Exported for testability
 export function getLernaVersion(
   lernaPackageFile: Partial<PackageFile>
diff --git a/lib/manager/npm/post-update/npm.ts b/lib/manager/npm/post-update/npm.ts
index 9405b60405..b087603fb6 100644
--- a/lib/manager/npm/post-update/npm.ts
+++ b/lib/manager/npm/post-update/npm.ts
@@ -11,12 +11,7 @@ import { ExecOptions, exec } from '../../../util/exec';
 import { move, pathExists, readFile, remove } from '../../../util/fs';
 import type { PostUpdateConfig, Upgrade } from '../../types';
 import { getNodeConstraint } from './node-version';
-
-export interface GenerateLockFileResult {
-  error?: boolean;
-  lockFile?: string;
-  stderr?: string;
-}
+import type { GenerateLockFileResult } from './types';
 
 export async function generateLockFile(
   cwd: string,
diff --git a/lib/manager/npm/post-update/pnpm.ts b/lib/manager/npm/post-update/pnpm.ts
index f6a802fc60..52a2c35008 100644
--- a/lib/manager/npm/post-update/pnpm.ts
+++ b/lib/manager/npm/post-update/pnpm.ts
@@ -8,13 +8,7 @@ import { ExecOptions, exec } from '../../../util/exec';
 import { readFile, remove } from '../../../util/fs';
 import type { PostUpdateConfig, Upgrade } from '../../types';
 import { getNodeConstraint } from './node-version';
-
-export interface GenerateLockFileResult {
-  error?: boolean;
-  lockFile?: string;
-  stderr?: string;
-  stdout?: string;
-}
+import type { GenerateLockFileResult } from './types';
 
 export async function generateLockFile(
   cwd: string,
diff --git a/lib/manager/npm/post-update/types.ts b/lib/manager/npm/post-update/types.ts
new file mode 100644
index 0000000000..035ac3d39d
--- /dev/null
+++ b/lib/manager/npm/post-update/types.ts
@@ -0,0 +1,34 @@
+import type { PackageFile } from '../../types';
+
+export interface DetermineLockFileDirsResult {
+  yarnLockDirs: string[];
+  npmLockDirs: string[];
+  pnpmShrinkwrapDirs: string[];
+  lernaJsonFiles: string[];
+}
+
+export interface AdditionalPackageFiles {
+  npm?: Partial<PackageFile>[];
+}
+
+export interface ArtifactError {
+  lockFile: string;
+  stderr: string;
+}
+
+export interface UpdatedArtifacts {
+  name: string;
+  contents: string | Buffer;
+}
+
+export interface WriteExistingFilesResult {
+  artifactErrors: ArtifactError[];
+  updatedArtifacts: UpdatedArtifacts[];
+}
+
+export interface GenerateLockFileResult {
+  error?: boolean;
+  lockFile?: string;
+  stderr?: string;
+  stdout?: string;
+}
diff --git a/lib/manager/npm/post-update/yarn.ts b/lib/manager/npm/post-update/yarn.ts
index f555bcbce7..595124ad61 100644
--- a/lib/manager/npm/post-update/yarn.ts
+++ b/lib/manager/npm/post-update/yarn.ts
@@ -14,12 +14,7 @@ import { ExecOptions, exec } from '../../../util/exec';
 import { readFile, remove } from '../../../util/fs';
 import type { PostUpdateConfig, Upgrade } from '../../types';
 import { getNodeConstraint } from './node-version';
-
-export interface GenerateLockFileResult {
-  error?: boolean;
-  lockFile?: string;
-  stderr?: string;
-}
+import { GenerateLockFileResult } from './types';
 
 export async function checkYarnrc(
   cwd: string
diff --git a/lib/manager/nuget/types.ts b/lib/manager/nuget/types.ts
index e2cbb13bf9..631f8114e7 100644
--- a/lib/manager/nuget/types.ts
+++ b/lib/manager/nuget/types.ts
@@ -9,3 +9,8 @@ export interface DotnetTool {
   readonly version: string;
   readonly commands: string[];
 }
+
+export interface Registry {
+  readonly url: string;
+  readonly name?: string;
+}
diff --git a/lib/manager/nuget/util.ts b/lib/manager/nuget/util.ts
index b18c97efdf..d7fcd54f03 100644
--- a/lib/manager/nuget/util.ts
+++ b/lib/manager/nuget/util.ts
@@ -5,6 +5,7 @@ import { XmlDocument } from 'xmldoc';
 import * as datasourceNuget from '../../datasource/nuget';
 import { logger } from '../../logger';
 import { readFile } from '../../util/fs';
+import type { Registry } from './types';
 
 async function readFileAsXmlDocument(file: string): Promise<XmlDocument> {
   try {
@@ -15,11 +16,6 @@ async function readFileAsXmlDocument(file: string): Promise<XmlDocument> {
   }
 }
 
-export interface Registry {
-  readonly url: string;
-  readonly name?: string;
-}
-
 /* istanbul ignore next */
 export function getRandomString(): string {
   return cryptoRandomString({ length: 16 });
diff --git a/lib/manager/pip_setup/extract.ts b/lib/manager/pip_setup/extract.ts
index e6692ade9e..e027433428 100644
--- a/lib/manager/pip_setup/extract.ts
+++ b/lib/manager/pip_setup/extract.ts
@@ -6,7 +6,8 @@ import { BinarySource } from '../../util/exec/common';
 import { isSkipComment } from '../../util/ignore';
 import { dependencyPattern } from '../pip_requirements/extract';
 import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
-import { PythonSetup, getExtractFile, parseReport } from './util';
+import type { PythonSetup } from './types';
+import { getExtractFile, parseReport } from './util';
 
 export const pythonVersions = ['python', 'python3', 'python3.8', 'python3.9'];
 let pythonAlias: string | null = null;
diff --git a/lib/manager/pip_setup/types.ts b/lib/manager/pip_setup/types.ts
new file mode 100644
index 0000000000..39187e14ce
--- /dev/null
+++ b/lib/manager/pip_setup/types.ts
@@ -0,0 +1,4 @@
+export interface PythonSetup {
+  extras_require: Record<string, string[]>;
+  install_requires: string[];
+}
diff --git a/lib/manager/pip_setup/util.ts b/lib/manager/pip_setup/util.ts
index 84b020c0df..88e7e70eec 100644
--- a/lib/manager/pip_setup/util.ts
+++ b/lib/manager/pip_setup/util.ts
@@ -2,6 +2,7 @@ import { dirname } from 'path';
 import { join } from 'upath';
 import dataFiles from '../../data-files.generated';
 import { ensureCacheDir, outputFile, readLocalFile } from '../../util/fs';
+import type { PythonSetup } from './types';
 
 // need to match filename in `data/extract.py`
 const REPORT = 'renovate-pip_setup-report.json';
@@ -21,11 +22,6 @@ export async function getExtractFile(): Promise<string> {
   return extractPy;
 }
 
-export interface PythonSetup {
-  extras_require: Record<string, string[]>;
-  install_requires: string[];
-}
-
 export async function parseReport(packageFile: string): Promise<PythonSetup> {
   const data = await readLocalFile(join(dirname(packageFile), REPORT), 'utf8');
   return JSON.parse(data);
diff --git a/lib/manager/pipenv/artifacts.spec.ts b/lib/manager/pipenv/artifacts.spec.ts
index 165edc209b..53019bc17c 100644
--- a/lib/manager/pipenv/artifacts.spec.ts
+++ b/lib/manager/pipenv/artifacts.spec.ts
@@ -7,7 +7,7 @@ import { setUtilConfig } from '../../util';
 import { BinarySource } from '../../util/exec/common';
 import * as docker from '../../util/exec/docker';
 import * as _env from '../../util/exec/env';
-import { StatusResult } from '../../util/git';
+import type { StatusResult } from '../../util/git';
 import * as pipenv from './artifacts';
 
 jest.mock('fs-extra');
diff --git a/lib/manager/pipenv/extract.ts b/lib/manager/pipenv/extract.ts
index 84c7e4fc34..ddd9107ded 100644
--- a/lib/manager/pipenv/extract.ts
+++ b/lib/manager/pipenv/extract.ts
@@ -6,6 +6,7 @@ import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import { localPathExists } from '../../util/fs';
 import type { PackageDependency, PackageFile } from '../types';
+import type { PipFile } from './types';
 
 // based on https://www.python.org/dev/peps/pep-0508/#names
 const packageRegex = /^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$/i;
@@ -16,27 +17,6 @@ const specifierPartPattern = `\\s*${rangePattern.replace(
   '?:'
 )}\\s*`;
 const specifierPattern = `${specifierPartPattern}(?:,${specifierPartPattern})*`;
-interface PipSource {
-  name: string;
-  url: string;
-}
-
-interface PipFile {
-  source: PipSource[];
-
-  packages?: Record<string, PipRequirement>;
-  'dev-packages'?: Record<string, PipRequirement>;
-  requires?: Record<string, string>;
-}
-
-interface PipRequirement {
-  index?: string;
-  version?: string;
-  path?: string;
-  file?: string;
-  git?: string;
-}
-
 function extractFromSection(
   pipfile: PipFile,
   section: 'packages' | 'dev-packages'
diff --git a/lib/manager/pipenv/types.ts b/lib/manager/pipenv/types.ts
new file mode 100644
index 0000000000..b3e914aea1
--- /dev/null
+++ b/lib/manager/pipenv/types.ts
@@ -0,0 +1,20 @@
+export interface PipSource {
+  name: string;
+  url: string;
+}
+
+export interface PipFile {
+  source: PipSource[];
+
+  packages?: Record<string, PipRequirement>;
+  'dev-packages'?: Record<string, PipRequirement>;
+  requires?: Record<string, string>;
+}
+
+export interface PipRequirement {
+  index?: string;
+  version?: string;
+  path?: string;
+  file?: string;
+  git?: string;
+}
diff --git a/lib/manager/sbt/extract.ts b/lib/manager/sbt/extract.ts
index 84c8daf4af..6b6b2dc5d2 100644
--- a/lib/manager/sbt/extract.ts
+++ b/lib/manager/sbt/extract.ts
@@ -5,6 +5,7 @@ import * as datasourceSbtPlugin from '../../datasource/sbt-plugin';
 import { get } from '../../versioning';
 import * as mavenVersioning from '../../versioning/maven';
 import type { PackageDependency, PackageFile } from '../types';
+import type { ParseContext, ParseOptions } from './types';
 
 const stripComment = (str: string): string => str.replace(/(^|\s+)\/\/.*$/, '');
 
@@ -102,12 +103,6 @@ const getVarInfo = (str: string, ctx: ParseContext): { val: string } => {
   return { val };
 };
 
-interface ParseContext {
-  scalaVersion: string;
-  variables: any;
-  depType?: string;
-}
-
 function parseDepExpr(
   expr: string,
   ctx: ParseContext
@@ -198,12 +193,6 @@ function parseDepExpr(
   return result;
 }
 
-interface ParseOptions {
-  isMultiDeps?: boolean;
-  scalaVersion?: string;
-  variables?: Record<string, any>;
-}
-
 function parseSbtLine(
   acc: PackageFile & ParseOptions,
   line: string,
diff --git a/lib/manager/sbt/types.ts b/lib/manager/sbt/types.ts
new file mode 100644
index 0000000000..7c0ef4c7f7
--- /dev/null
+++ b/lib/manager/sbt/types.ts
@@ -0,0 +1,11 @@
+export interface ParseContext {
+  scalaVersion: string;
+  variables: any;
+  depType?: string;
+}
+
+export interface ParseOptions {
+  isMultiDeps?: boolean;
+  scalaVersion?: string;
+  variables?: Record<string, any>;
+}
diff --git a/lib/manager/swift/extract.ts b/lib/manager/swift/extract.ts
index a30b57287d..f7feb08408 100644
--- a/lib/manager/swift/extract.ts
+++ b/lib/manager/swift/extract.ts
@@ -1,5 +1,6 @@
 import * as datasourceGitTags from '../../datasource/git-tags';
 import type { PackageDependency, PackageFile } from '../types';
+import type { MatchResult } from './types';
 
 const regExps = {
   wildcard: /^.*?/,
@@ -87,13 +88,6 @@ function searchKeysForState(state): (keyof typeof regExps)[] {
       return [DEPS];
   }
 }
-interface MatchResult {
-  idx: number;
-  len: number;
-  label: string;
-  substr: string;
-}
-
 function getMatch(str: string, state: string): MatchResult | null {
   const keys = searchKeysForState(state);
   let result = null;
diff --git a/lib/manager/swift/types.ts b/lib/manager/swift/types.ts
new file mode 100644
index 0000000000..ebfaa18c16
--- /dev/null
+++ b/lib/manager/swift/types.ts
@@ -0,0 +1,6 @@
+export interface MatchResult {
+  idx: number;
+  len: number;
+  label: string;
+  substr: string;
+}
diff --git a/lib/manager/terraform/common.ts b/lib/manager/terraform/common.ts
new file mode 100644
index 0000000000..25be93cd16
--- /dev/null
+++ b/lib/manager/terraform/common.ts
@@ -0,0 +1,28 @@
+export enum TerraformDependencyTypes {
+  unknown = 'unknown',
+  module = 'module',
+  provider = 'provider',
+  required_providers = 'required_providers',
+  resource = 'resource',
+  terraform_version = 'terraform_version',
+}
+
+export enum TerraformResourceTypes {
+  unknown = 'unknown',
+  /**
+   * https://www.terraform.io/docs/providers/docker/r/container.html
+   */
+  docker_container = 'docker_container',
+  /**
+   * https://www.terraform.io/docs/providers/docker/r/image.html
+   */
+  docker_image = 'docker_image',
+  /**
+   * https://www.terraform.io/docs/providers/docker/r/service.html
+   */
+  docker_service = 'docker_service',
+  /**
+   * https://www.terraform.io/docs/providers/helm/r/release.html
+   */
+  helm_release = 'helm_release',
+}
diff --git a/lib/manager/terraform/extract.ts b/lib/manager/terraform/extract.ts
index 0048bde408..889d5df024 100644
--- a/lib/manager/terraform/extract.ts
+++ b/lib/manager/terraform/extract.ts
@@ -1,5 +1,6 @@
 import { logger } from '../../logger';
 import type { PackageDependency, PackageFile } from '../types';
+import { TerraformDependencyTypes } from './common';
 import { analyseTerraformModule, extractTerraformModule } from './modules';
 import {
   analyzeTerraformProvider,
@@ -17,9 +18,8 @@ import {
   analyseTerraformResource,
   extractTerraformResource,
 } from './resources';
+import type { TerraformManagerData } from './types';
 import {
-  TerraformDependencyTypes,
-  TerraformManagerData,
   checkFileContainsDependency,
   getTerraformDependencyType,
 } from './util';
diff --git a/lib/manager/terraform/modules.ts b/lib/manager/terraform/modules.ts
index d4d645565f..f1deb1182a 100644
--- a/lib/manager/terraform/modules.ts
+++ b/lib/manager/terraform/modules.ts
@@ -4,8 +4,9 @@ import * as datasourceTerraformModule from '../../datasource/terraform-module';
 import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import type { PackageDependency } from '../types';
+import { TerraformDependencyTypes } from './common';
 import { extractTerraformProvider } from './providers';
-import { ExtractionResult, TerraformDependencyTypes } from './util';
+import type { ExtractionResult } from './types';
 
 export const githubRefMatchRegex = /github\.com([/:])(?<project>[^/]+\/[a-z0-9-_.]+).*\?ref=(?<tag>.*)$/i;
 export const gitTagsRefMatchRegex = /(?:git::)?(?<url>(?:http|https|ssh):\/\/(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/;
diff --git a/lib/manager/terraform/providers.ts b/lib/manager/terraform/providers.ts
index aa06ad0d73..f5679c9b81 100644
--- a/lib/manager/terraform/providers.ts
+++ b/lib/manager/terraform/providers.ts
@@ -3,11 +3,9 @@ import * as datasourceTerraformProvider from '../../datasource/terraform-provide
 import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import type { PackageDependency } from '../types';
-import {
-  ExtractionResult,
-  TerraformDependencyTypes,
-  keyValueExtractionRegex,
-} from './util';
+import { TerraformDependencyTypes } from './common';
+import type { ExtractionResult } from './types';
+import { keyValueExtractionRegex } from './util';
 
 export const sourceExtractionRegex = /^(?:(?<hostname>(?:[a-zA-Z0-9]+\.+)+[a-zA-Z0-9]+)\/)?(?:(?<namespace>[^/]+)\/)?(?<type>[^/]+)/;
 
diff --git a/lib/manager/terraform/required-providers.ts b/lib/manager/terraform/required-providers.ts
index 44b1186210..7d519ed74a 100644
--- a/lib/manager/terraform/required-providers.ts
+++ b/lib/manager/terraform/required-providers.ts
@@ -1,10 +1,8 @@
 import type { PackageDependency } from '../types';
+import { TerraformDependencyTypes } from './common';
 import { analyzeTerraformProvider } from './providers';
-import {
-  ExtractionResult,
-  TerraformDependencyTypes,
-  keyValueExtractionRegex,
-} from './util';
+import type { ExtractionResult } from './types';
+import { keyValueExtractionRegex } from './util';
 
 export const providerBlockExtractionRegex = /^\s*(?<key>[^\s]+)\s+=\s+{/;
 
diff --git a/lib/manager/terraform/required-version.ts b/lib/manager/terraform/required-version.ts
index c8bb1e4dad..d5f6020389 100644
--- a/lib/manager/terraform/required-version.ts
+++ b/lib/manager/terraform/required-version.ts
@@ -1,11 +1,9 @@
 import * as datasourceGithubTags from '../../datasource/github-tags';
 import { logger } from '../../logger';
 import type { PackageDependency } from '../types';
-import {
-  ExtractionResult,
-  TerraformDependencyTypes,
-  keyValueExtractionRegex,
-} from './util';
+import { TerraformDependencyTypes } from './common';
+import type { ExtractionResult } from './types';
+import { keyValueExtractionRegex } from './util';
 
 export function extractTerraformRequiredVersion(
   startingLine: number,
diff --git a/lib/manager/terraform/resources.ts b/lib/manager/terraform/resources.ts
index 4937a8e98e..7cf7799639 100644
--- a/lib/manager/terraform/resources.ts
+++ b/lib/manager/terraform/resources.ts
@@ -2,11 +2,9 @@ import * as datasourceHelm from '../../datasource/helm';
 import { SkipReason } from '../../types';
 import { getDep } from '../dockerfile/extract';
 import type { PackageDependency } from '../types';
+import { TerraformDependencyTypes, TerraformResourceTypes } from './common';
+import type { ExtractionResult, ResourceManagerData } from './types';
 import {
-  ExtractionResult,
-  ResourceManagerData,
-  TerraformDependencyTypes,
-  TerraformResourceTypes,
   checkIfStringIsPath,
   keyValueExtractionRegex,
   resourceTypeExtractionRegex,
diff --git a/lib/manager/terraform/types.ts b/lib/manager/terraform/types.ts
new file mode 100644
index 0000000000..865289501d
--- /dev/null
+++ b/lib/manager/terraform/types.ts
@@ -0,0 +1,22 @@
+import type { PackageDependency } from '../types';
+import type {
+  TerraformDependencyTypes,
+  TerraformResourceTypes,
+} from './common';
+
+export interface ExtractionResult {
+  lineNumber: number;
+  dependencies: PackageDependency[];
+}
+
+export interface TerraformManagerData {
+  terraformDependencyType: TerraformDependencyTypes;
+}
+
+export interface ResourceManagerData extends TerraformManagerData {
+  resourceType?: TerraformResourceTypes;
+  chart?: string;
+  image?: string;
+  name?: string;
+  repository?: string;
+}
diff --git a/lib/manager/terraform/util.spec.ts b/lib/manager/terraform/util.spec.ts
index 678464fc52..367cb4ad1a 100644
--- a/lib/manager/terraform/util.spec.ts
+++ b/lib/manager/terraform/util.spec.ts
@@ -1,5 +1,6 @@
 import { getName } from '../../../test/util';
-import { TerraformDependencyTypes, getTerraformDependencyType } from './util';
+import { TerraformDependencyTypes } from './common';
+import { getTerraformDependencyType } from './util';
 
 describe(getName(), () => {
   describe('getTerraformDependencyType()', () => {
diff --git a/lib/manager/terraform/util.ts b/lib/manager/terraform/util.ts
index ff770199e6..2ee93770e1 100644
--- a/lib/manager/terraform/util.ts
+++ b/lib/manager/terraform/util.ts
@@ -1,54 +1,8 @@
-import type { PackageDependency } from '../types';
+import { TerraformDependencyTypes } from './common';
 
 export const keyValueExtractionRegex = /^\s*(?<key>[^\s]+)\s+=\s+"(?<value>[^"]+)"\s*$/;
 export const resourceTypeExtractionRegex = /^\s*resource\s+"(?<type>[^\s]+)"\s+"(?<name>[^"]+)"\s*{/;
 
-export interface ExtractionResult {
-  lineNumber: number;
-  dependencies: PackageDependency[];
-}
-
-export enum TerraformDependencyTypes {
-  unknown = 'unknown',
-  module = 'module',
-  provider = 'provider',
-  required_providers = 'required_providers',
-  resource = 'resource',
-  terraform_version = 'terraform_version',
-}
-
-export interface TerraformManagerData {
-  terraformDependencyType: TerraformDependencyTypes;
-}
-
-export enum TerraformResourceTypes {
-  unknown = 'unknown',
-  /**
-   * https://www.terraform.io/docs/providers/docker/r/container.html
-   */
-  docker_container = 'docker_container',
-  /**
-   * https://www.terraform.io/docs/providers/docker/r/image.html
-   */
-  docker_image = 'docker_image',
-  /**
-   * https://www.terraform.io/docs/providers/docker/r/service.html
-   */
-  docker_service = 'docker_service',
-  /**
-   * https://www.terraform.io/docs/providers/helm/r/release.html
-   */
-  helm_release = 'helm_release',
-}
-
-export interface ResourceManagerData extends TerraformManagerData {
-  resourceType?: TerraformResourceTypes;
-  chart?: string;
-  image?: string;
-  name?: string;
-  repository?: string;
-}
-
 export function getTerraformDependencyType(
   value: string
 ): TerraformDependencyTypes {
diff --git a/lib/manager/terragrunt/common.ts b/lib/manager/terragrunt/common.ts
new file mode 100644
index 0000000000..c5a699e242
--- /dev/null
+++ b/lib/manager/terragrunt/common.ts
@@ -0,0 +1,8 @@
+export enum TerragruntResourceTypes {
+  unknown = 'unknown',
+}
+
+export enum TerragruntDependencyTypes {
+  unknown = 'unknown',
+  terragrunt = 'terraform',
+}
diff --git a/lib/manager/terragrunt/extract.ts b/lib/manager/terragrunt/extract.ts
index ce7ba4d1e5..6f114a45f1 100644
--- a/lib/manager/terragrunt/extract.ts
+++ b/lib/manager/terragrunt/extract.ts
@@ -1,9 +1,9 @@
 import { logger } from '../../logger';
 import type { PackageDependency, PackageFile } from '../types';
+import { TerragruntDependencyTypes } from './common';
 import { analyseTerragruntModule, extractTerragruntModule } from './modules';
+import type { TerraformManagerData } from './types';
 import {
-  TerraformManagerData,
-  TerragruntDependencyTypes,
   checkFileContainsDependency,
   getTerragruntDependencyType,
 } from './util';
diff --git a/lib/manager/terragrunt/modules.ts b/lib/manager/terragrunt/modules.ts
index e11e12e20b..5a0703006c 100644
--- a/lib/manager/terragrunt/modules.ts
+++ b/lib/manager/terragrunt/modules.ts
@@ -4,8 +4,9 @@ import * as datasourceTerragruntModule from '../../datasource/terraform-module';
 import { logger } from '../../logger';
 import { SkipReason } from '../../types';
 import type { PackageDependency } from '../types';
+import { TerragruntDependencyTypes } from './common';
 import { extractTerragruntProvider } from './providers';
-import { ExtractionResult, TerragruntDependencyTypes } from './util';
+import type { ExtractionResult } from './types';
 
 export const githubRefMatchRegex = /github\.com([/:])(?<project>[^/]+\/[a-z0-9-_.]+).*\?ref=(?<tag>.*)$/i;
 export const gitTagsRefMatchRegex = /(?:git::)?(?<url>(?:http|https|ssh):\/\/(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/;
diff --git a/lib/manager/terragrunt/providers.ts b/lib/manager/terragrunt/providers.ts
index cdda18bee5..b0c24e0844 100644
--- a/lib/manager/terragrunt/providers.ts
+++ b/lib/manager/terragrunt/providers.ts
@@ -1,9 +1,7 @@
 import type { PackageDependency } from '../types';
-import {
-  ExtractionResult,
-  TerragruntDependencyTypes,
-  keyValueExtractionRegex,
-} from './util';
+import { TerragruntDependencyTypes } from './common';
+import type { ExtractionResult } from './types';
+import { keyValueExtractionRegex } from './util';
 
 export const sourceExtractionRegex = /^(?:(?<hostname>(?:[a-zA-Z0-9]+\.+)+[a-zA-Z0-9]+)\/)?(?:(?<namespace>[^/]+)\/)?(?<type>[^/]+)/;
 
diff --git a/lib/manager/terragrunt/types.ts b/lib/manager/terragrunt/types.ts
new file mode 100644
index 0000000000..0f474282e3
--- /dev/null
+++ b/lib/manager/terragrunt/types.ts
@@ -0,0 +1,22 @@
+import type { PackageDependency } from '../types';
+import type {
+  TerragruntDependencyTypes,
+  TerragruntResourceTypes,
+} from './common';
+
+export interface ExtractionResult {
+  lineNumber: number;
+  dependencies: PackageDependency[];
+}
+
+export interface TerraformManagerData {
+  terragruntDependencyType: TerragruntDependencyTypes;
+}
+
+export interface ResourceManagerData extends TerraformManagerData {
+  resourceType?: TerragruntResourceTypes;
+  chart?: string;
+  image?: string;
+  name?: string;
+  repository?: string;
+}
diff --git a/lib/manager/terragrunt/util.spec.ts b/lib/manager/terragrunt/util.spec.ts
index cc37ccedaa..26e12fe03d 100644
--- a/lib/manager/terragrunt/util.spec.ts
+++ b/lib/manager/terragrunt/util.spec.ts
@@ -1,5 +1,6 @@
 import { getName } from '../../../test/util';
-import { TerragruntDependencyTypes, getTerragruntDependencyType } from './util';
+import { TerragruntDependencyTypes } from './common';
+import { getTerragruntDependencyType } from './util';
 
 describe(getName(), () => {
   describe('getTerragruntDependencyType()', () => {
diff --git a/lib/manager/terragrunt/util.ts b/lib/manager/terragrunt/util.ts
index 299e8cc577..63ebc18956 100644
--- a/lib/manager/terragrunt/util.ts
+++ b/lib/manager/terragrunt/util.ts
@@ -1,36 +1,7 @@
-import type { PackageDependency } from '../types';
+import { TerragruntDependencyTypes } from './common';
 
 export const keyValueExtractionRegex = /^\s*source\s+=\s+"(?<value>[^"]+)"\s*$/;
 
-export interface ExtractionResult {
-  lineNumber: number;
-  dependencies: PackageDependency[];
-}
-
-export enum TerragruntDependencyTypes {
-  unknown = 'unknown',
-  terragrunt = 'terraform',
-}
-
-export interface TerraformManagerData {
-  terragruntDependencyType: TerragruntDependencyTypes;
-}
-
-export enum TerragruntResourceTypes {
-  unknown = 'unknown',
-  /**
-   * https://www.terraform.io/docs/providers/docker/r/container.html
-   */
-}
-
-export interface ResourceManagerData extends TerraformManagerData {
-  resourceType?: TerragruntResourceTypes;
-  chart?: string;
-  image?: string;
-  name?: string;
-  repository?: string;
-}
-
 export function getTerragruntDependencyType(
   value: string
 ): TerragruntDependencyTypes {
diff --git a/lib/util/cache/repository/index.ts b/lib/util/cache/repository/index.ts
index 4c540193a3..c8949ac215 100644
--- a/lib/util/cache/repository/index.ts
+++ b/lib/util/cache/repository/index.ts
@@ -5,50 +5,11 @@ import type {
   RepositoryCacheConfig,
 } from '../../../config/types';
 import { logger } from '../../../logger';
-import type { PackageFile } from '../../../manager/types';
-import type { RepoInitConfig } from '../../../workers/repository/init/types';
+import type { Cache } from './types';
 
 // Increment this whenever there could be incompatibilities between old and new cache structure
 export const CACHE_REVISION = 8;
 
-export interface BaseBranchCache {
-  sha: string; // branch commit sha
-  configHash: string; // object hash of config
-  packageFiles: Record<string, PackageFile[]>; // extract result
-}
-
-export interface BranchUpgradeCache {
-  currentDigest?: string;
-  currentValue?: string;
-  datasource?: string;
-  depName?: string;
-  fixedVersion?: string;
-  currentVersion?: string;
-  lookupName?: string;
-  newDigest?: string;
-  newValue?: string;
-  newVersion?: string;
-  sourceUrl?: string;
-}
-
-export interface BranchCache {
-  automerge: boolean;
-  branchName: string;
-  isModified: boolean;
-  prNo: number | null;
-  sha: string | null;
-  parentSha: string | null;
-  upgrades: BranchUpgradeCache[];
-}
-
-export interface Cache {
-  branches?: BranchCache[];
-  repository?: string;
-  revision?: number;
-  init?: RepoInitConfig;
-  scan?: Record<string, BaseBranchCache>;
-}
-
 let repositoryCache: RepositoryCacheConfig = 'disabled';
 let cacheFileName: string;
 let cache: Cache = Object.create({});
diff --git a/lib/util/cache/repository/types.ts b/lib/util/cache/repository/types.ts
new file mode 100644
index 0000000000..3a7995b559
--- /dev/null
+++ b/lib/util/cache/repository/types.ts
@@ -0,0 +1,40 @@
+import type { PackageFile } from '../../../manager/types';
+import type { RepoInitConfig } from '../../../workers/repository/init/types';
+
+export interface BaseBranchCache {
+  sha: string; // branch commit sha
+  configHash: string; // object hash of config
+  packageFiles: Record<string, PackageFile[]>; // extract result
+}
+
+export interface BranchUpgradeCache {
+  currentDigest?: string;
+  currentValue?: string;
+  datasource?: string;
+  depName?: string;
+  fixedVersion?: string;
+  currentVersion?: string;
+  lookupName?: string;
+  newDigest?: string;
+  newValue?: string;
+  newVersion?: string;
+  sourceUrl?: string;
+}
+
+export interface BranchCache {
+  automerge: boolean;
+  branchName: string;
+  isModified: boolean;
+  prNo: number | null;
+  sha: string | null;
+  parentSha: string | null;
+  upgrades: BranchUpgradeCache[];
+}
+
+export interface Cache {
+  branches?: BranchCache[];
+  repository?: string;
+  revision?: number;
+  init?: RepoInitConfig;
+  scan?: Record<string, BaseBranchCache>;
+}
diff --git a/lib/workers/branch/index.spec.ts b/lib/workers/branch/index.spec.ts
index d14c901d56..0099908bab 100644
--- a/lib/workers/branch/index.spec.ts
+++ b/lib/workers/branch/index.spec.ts
@@ -12,7 +12,7 @@ import {
   REPOSITORY_CHANGED,
 } from '../../constants/error-messages';
 import * as _npmPostExtract from '../../manager/npm/post-update';
-import type { WriteExistingFilesResult } from '../../manager/npm/post-update';
+import type { WriteExistingFilesResult } from '../../manager/npm/post-update/types';
 import { PrState } from '../../types';
 import * as _exec from '../../util/exec';
 import { File, StatusResult } from '../../util/git';
diff --git a/lib/workers/repository/cache.ts b/lib/workers/repository/cache.ts
index 1104be2bc4..e8f9c4bcd5 100644
--- a/lib/workers/repository/cache.ts
+++ b/lib/workers/repository/cache.ts
@@ -2,11 +2,11 @@
 
 import { logger } from '../../logger';
 import { platform } from '../../platform';
-import {
+import { getCache } from '../../util/cache/repository';
+import type {
   BranchCache,
   BranchUpgradeCache,
-  getCache,
-} from '../../util/cache/repository';
+} from '../../util/cache/repository/types';
 import {
   getBranchCommit,
   getBranchParentSha,
-- 
GitLab