From be2a89520bfa2ae6f2d6eb3d4e633ceee7dc37c5 Mon Sep 17 00:00:00 2001
From: RahulGautamSingh <rahultesnik@gmail.com>
Date: Tue, 6 Jun 2023 01:03:30 +0545
Subject: [PATCH] refactor: replace as assertions (#22442)

---
 .../migrations/custom/dep-types-migration.ts  |  2 +-
 lib/modules/datasource/docker/index.spec.ts   |  1 -
 .../manager/gitlabci-include/common.ts        |  2 +-
 .../extract/consistent-versions-plugin.ts     |  4 +-
 lib/modules/manager/gradle/utils.spec.ts      | 18 ++++-----
 lib/modules/platform/azure/index.ts           |  2 +-
 lib/modules/platform/gitea/index.spec.ts      | 15 +++++---
 lib/modules/platform/github/index.spec.ts     |  2 +-
 lib/util/exec/docker/index.spec.ts            | 37 +++++++++++++------
 lib/util/exec/hermit.ts                       |  2 +-
 .../github/graphql/datasource-fetcher.spec.ts |  3 +-
 lib/util/host-rules.spec.ts                   | 15 ++++----
 lib/util/host-rules.ts                        |  2 +-
 lib/workers/repository/extract/index.spec.ts  | 15 ++++++--
 lib/workers/repository/finalize/prune.spec.ts | 34 +++++++++--------
 lib/workers/repository/init/index.spec.ts     | 14 ++++---
 .../repository/onboarding/pr/pr-list.spec.ts  |  6 ++-
 lib/workers/repository/process/limits.spec.ts | 12 ++++--
 .../update/branch/automerge.spec.ts           | 11 +++++-
 .../update/branch/check-existing.spec.ts      | 12 +++---
 .../update/branch/get-updated.spec.ts         | 24 ++++++++----
 .../repository/update/branch/index.spec.ts    | 21 ++++++-----
 .../update/pr/changelog/release-notes.spec.ts |  5 ++-
 .../repository/update/pr/participants.spec.ts |  4 +-
 lib/workers/repository/updates/generate.ts    |  2 +-
 25 files changed, 161 insertions(+), 104 deletions(-)

diff --git a/lib/config/migrations/custom/dep-types-migration.ts b/lib/config/migrations/custom/dep-types-migration.ts
index f7a824729b..621c32413f 100644
--- a/lib/config/migrations/custom/dep-types-migration.ts
+++ b/lib/config/migrations/custom/dep-types-migration.ts
@@ -15,7 +15,7 @@ export class DepTypesMigration extends AbstractMigration {
       packageRules.push({
         matchDepTypes: [key],
         ...value,
-      } as PackageRule);
+      });
     }
 
     if (is.array(value)) {
diff --git a/lib/modules/datasource/docker/index.spec.ts b/lib/modules/datasource/docker/index.spec.ts
index 6d1ffb0558..15ed77dbad 100644
--- a/lib/modules/datasource/docker/index.spec.ts
+++ b/lib/modules/datasource/docker/index.spec.ts
@@ -2011,7 +2011,6 @@ describe('modules/datasource/docker/index', () => {
     });
 
     it('supports ghcr', async () => {
-      hostRules.find.mockResolvedValue({} as never);
       httpMock
         .scope('https://ghcr.io/v2', {
           badheaders: ['authorization'],
diff --git a/lib/modules/manager/gitlabci-include/common.ts b/lib/modules/manager/gitlabci-include/common.ts
index da163cb0ea..3c0720d019 100644
--- a/lib/modules/manager/gitlabci-include/common.ts
+++ b/lib/modules/manager/gitlabci-include/common.ts
@@ -13,7 +13,7 @@ export function isNonEmptyObject(obj: any): boolean {
 export function filterIncludeFromGitlabPipeline(
   pipeline: GitlabPipeline
 ): GitlabPipeline {
-  const pipeline_without_include = {} as GitlabPipeline;
+  const pipeline_without_include: GitlabPipeline = {};
   for (const key of Object.keys(pipeline).filter((key) => key !== 'include')) {
     const pipeline_key = key as keyof typeof pipeline;
     pipeline_without_include[pipeline_key] = pipeline[pipeline_key];
diff --git a/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts b/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts
index 025503c35e..46b971dd02 100644
--- a/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts
+++ b/lib/modules/manager/gradle/extract/consistent-versions-plugin.ts
@@ -80,7 +80,7 @@ export function parseGcv(
         currentValue: versionAndPosition.version,
         lockedVersion: lockFileMap.get(propDep)?.version,
         depType: lockFileMap.get(propDep)?.depType,
-      } as PackageDependency<GradleManagerData>;
+      } satisfies PackageDependency<GradleManagerData>;
       extractedDeps.push(newDep);
       // Remove from the lockfile map so the same exact lib will not be included in globbing
       lockFileMap.delete(propDep);
@@ -102,7 +102,7 @@ export function parseGcv(
           lockedVersion: lockVersionAndDepType.version,
           depType: lockVersionAndDepType.depType,
           groupName: propDepGlob,
-        } as PackageDependency<GradleManagerData>;
+        } satisfies PackageDependency<GradleManagerData>;
         extractedDeps.push(newDep);
         // Remove from the lockfile map so the same lib will not be included in more generic globs later
         lockFileMap.delete(exactDep);
diff --git a/lib/modules/manager/gradle/utils.spec.ts b/lib/modules/manager/gradle/utils.spec.ts
index ac8bfb824d..bad712dfd8 100644
--- a/lib/modules/manager/gradle/utils.spec.ts
+++ b/lib/modules/manager/gradle/utils.spec.ts
@@ -153,17 +153,17 @@ describe('modules/manager/gradle/utils', () => {
   it('getVars', () => {
     const registry: VariableRegistry = {
       [toAbsolutePath('/foo')]: {
-        foo: { key: 'foo', value: 'FOO' } as never,
-        bar: { key: 'bar', value: 'BAR' } as never,
-        baz: { key: 'baz', value: 'BAZ' } as never,
-        qux: { key: 'qux', value: 'QUX' } as never,
+        foo: { key: 'foo', value: 'FOO' },
+        bar: { key: 'bar', value: 'BAR' },
+        baz: { key: 'baz', value: 'BAZ' },
+        qux: { key: 'qux', value: 'QUX' },
       },
       [toAbsolutePath('/foo/bar')]: {
-        foo: { key: 'foo', value: 'foo' } as never,
+        foo: { key: 'foo', value: 'foo' },
       },
       [toAbsolutePath('/foo/bar/baz')]: {
-        bar: { key: 'bar', value: 'bar' } as never,
-        baz: { key: 'baz', value: 'baz' } as never,
+        bar: { key: 'bar', value: 'bar' },
+        baz: { key: 'baz', value: 'baz' },
       },
     };
     const res = getVars(registry, '/foo/bar/baz/build.gradle');
@@ -178,8 +178,8 @@ describe('modules/manager/gradle/utils', () => {
   it('updateVars', () => {
     const registry: VariableRegistry = {
       [toAbsolutePath('/foo/bar/baz')]: {
-        bar: { key: 'bar', value: 'bar' } as never,
-        baz: { key: 'baz', value: 'baz' } as never,
+        bar: { key: 'bar', value: 'bar' },
+        baz: { key: 'baz', value: 'baz' },
       },
     };
 
diff --git a/lib/modules/platform/azure/index.ts b/lib/modules/platform/azure/index.ts
index def6948ea1..a3e0f0d6db 100644
--- a/lib/modules/platform/azure/index.ts
+++ b/lib/modules/platform/azure/index.ts
@@ -143,7 +143,7 @@ export async function getRawFile(
 
   const versionDescriptor: GitVersionDescriptor = {
     version: branchOrTag,
-  } as GitVersionDescriptor;
+  } satisfies GitVersionDescriptor;
 
   const buf = await azureApiGit.getItemContent(
     repoId,
diff --git a/lib/modules/platform/gitea/index.spec.ts b/lib/modules/platform/gitea/index.spec.ts
index 4b61916037..a306b76a7b 100644
--- a/lib/modules/platform/gitea/index.spec.ts
+++ b/lib/modules/platform/gitea/index.spec.ts
@@ -1921,7 +1921,8 @@ describe('modules/platform/gitea/index', () => {
       const data = { foo: 'bar' };
       helper.getRepoContents.mockResolvedValueOnce({
         contentString: JSON.stringify(data),
-      } as never);
+        path: 'path',
+      });
       await initFakeRepo({ full_name: 'some/repo' });
       const res = await gitea.getJsonFile('file.json');
       expect(res).toEqual(data);
@@ -1931,7 +1932,8 @@ describe('modules/platform/gitea/index', () => {
       const data = { foo: 'bar' };
       helper.getRepoContents.mockResolvedValueOnce({
         contentString: JSON.stringify(data),
-      } as never);
+        path: 'path',
+      });
       await initFakeRepo({ full_name: 'different/repo' });
       const res = await gitea.getJsonFile('file.json', 'different/repo');
       expect(res).toEqual(data);
@@ -1941,7 +1943,8 @@ describe('modules/platform/gitea/index', () => {
       const data = { foo: 'bar' };
       helper.getRepoContents.mockResolvedValueOnce({
         contentString: JSON.stringify(data),
-      } as never);
+        path: 'path',
+      });
       await initFakeRepo({ full_name: 'some/repo' });
       const res = await gitea.getJsonFile('file.json', 'some/repo', 'dev');
       expect(res).toEqual(data);
@@ -1956,7 +1959,8 @@ describe('modules/platform/gitea/index', () => {
       `;
       helper.getRepoContents.mockResolvedValueOnce({
         contentString: json5Data,
-      } as never);
+        path: 'path',
+      });
       await initFakeRepo({ full_name: 'some/repo' });
       const res = await gitea.getJsonFile('file.json5');
       expect(res).toEqual({ foo: 'bar' });
@@ -1965,7 +1969,8 @@ describe('modules/platform/gitea/index', () => {
     it('throws on malformed JSON', async () => {
       helper.getRepoContents.mockResolvedValueOnce({
         contentString: '!@#',
-      } as never);
+        path: 'path',
+      });
       await initFakeRepo({ full_name: 'some/repo' });
       await expect(gitea.getJsonFile('file.json')).rejects.toThrow();
     });
diff --git a/lib/modules/platform/github/index.spec.ts b/lib/modules/platform/github/index.spec.ts
index ba40d4a3aa..3714876461 100644
--- a/lib/modules/platform/github/index.spec.ts
+++ b/lib/modules/platform/github/index.spec.ts
@@ -2165,7 +2165,7 @@ describe('modules/platform/github/index', () => {
             state: 'closed',
           },
         ]);
-      await github.initRepo({ repository: 'some/repo' } as never);
+      await github.initRepo({ repository: 'some/repo' });
 
       const res = await github.findPr({
         branchName: 'branch-a',
diff --git a/lib/util/exec/docker/index.spec.ts b/lib/util/exec/docker/index.spec.ts
index cdbfade271..3542031c09 100644
--- a/lib/util/exec/docker/index.spec.ts
+++ b/lib/util/exec/docker/index.spec.ts
@@ -1,8 +1,9 @@
 import { mockExecAll, mockExecSequence } from '../../../../test/exec-util';
+import { partial } from '../../../../test/util';
 import { GlobalConfig } from '../../../config/global';
 import { SYSTEM_INSUFFICIENT_MEMORY } from '../../../constants/error-messages';
 import { logger } from '../../../logger';
-import { getPkgReleases as _getPkgReleases } from '../../../modules/datasource';
+import * as modulesDatasource from '../../../modules/datasource';
 import type { VolumeOption } from '../types';
 import {
   generateDockerCommand,
@@ -14,8 +15,6 @@ import {
   sideCarImage,
 } from '.';
 
-const getPkgReleases: jest.Mock<typeof _getPkgReleases> =
-  _getPkgReleases as any;
 jest.mock('../../../modules/datasource');
 
 describe('util/exec/docker/index', () => {
@@ -56,13 +55,15 @@ describe('util/exec/docker/index', () => {
     });
 
     it('returns "latest" for bad release results', async () => {
-      getPkgReleases.mockResolvedValueOnce(undefined as never);
+      jest
+        .spyOn(modulesDatasource, 'getPkgReleases')
+        .mockResolvedValueOnce(undefined as never)
+        .mockResolvedValueOnce(partial<modulesDatasource.ReleaseResult>())
+        .mockResolvedValueOnce(
+          partial<modulesDatasource.ReleaseResult>({ releases: [] })
+        );
       expect(await getDockerTag('foo', '1.2.3', 'semver')).toBe('latest');
-
-      getPkgReleases.mockResolvedValueOnce({} as never);
       expect(await getDockerTag('foo', '1.2.3', 'semver')).toBe('latest');
-
-      getPkgReleases.mockResolvedValueOnce({ releases: [] } as never);
       expect(await getDockerTag('foo', '1.2.3', 'semver')).toBe('latest');
     });
 
@@ -87,7 +88,11 @@ describe('util/exec/docker/index', () => {
         { version: '2.1.1' },
         { version: '2.1.2' },
       ];
-      getPkgReleases.mockResolvedValueOnce({ releases } as never);
+      jest
+        .spyOn(modulesDatasource, 'getPkgReleases')
+        .mockResolvedValueOnce(
+          partial<modulesDatasource.ReleaseResult>({ releases })
+        );
       expect(await getDockerTag('foo', '^1.2.3', 'npm')).toBe('1.9.9');
     });
 
@@ -98,7 +103,11 @@ describe('util/exec/docker/index', () => {
         { version: '14.0.2' },
         { version: '15.0.2' },
       ];
-      getPkgReleases.mockResolvedValueOnce({ releases } as never);
+      jest
+        .spyOn(modulesDatasource, 'getPkgReleases')
+        .mockResolvedValueOnce(
+          partial<modulesDatasource.ReleaseResult>({ releases })
+        );
       expect(await getDockerTag('foo', '>=12', 'node')).toBe('14.0.2');
     });
   });
@@ -291,9 +300,13 @@ describe('util/exec/docker/index', () => {
 
     // TODO: it('handles tag constraint', async () => {
     //   mockExecAll();
-    //   getPkgReleases.mockResolvedValueOnce({
+    // jest
+    // .spyOn(modulesDatasource, 'getPkgReleases')
+    // .mockResolvedValue(
+    //   partial<modulesDatasource.ReleaseResult>({
     //     releases: [{ version: '5.5.5' }, { version: '6.0.0' }],
-    //   } as never);
+    //   })
+    // );
     //   const res = await generateDockerCommand(commands, preCommands, {
     //     ...dockerOptions,
     //   });
diff --git a/lib/util/exec/hermit.ts b/lib/util/exec/hermit.ts
index 34aae3e8d0..f28e053ad8 100644
--- a/lib/util/exec/hermit.ts
+++ b/lib/util/exec/hermit.ts
@@ -36,7 +36,7 @@ export async function getHermitEnvs(
 
   const lines = hermitEnvResp.stdout.split(os.EOL);
 
-  const out = {} as Record<string, string>;
+  const out: Record<string, string> = {};
 
   for (const line of lines) {
     const trimmedLine = line.trim();
diff --git a/lib/util/github/graphql/datasource-fetcher.spec.ts b/lib/util/github/graphql/datasource-fetcher.spec.ts
index 082d9bad32..bed035a564 100644
--- a/lib/util/github/graphql/datasource-fetcher.spec.ts
+++ b/lib/util/github/graphql/datasource-fetcher.spec.ts
@@ -1,5 +1,6 @@
 import AggregateError from 'aggregate-error';
 import * as httpMock from '../../../../test/http-mock';
+import { partial } from '../../../../test/util';
 import { GithubGraphqlResponse, GithubHttp } from '../../http/github';
 import { range } from '../../range';
 import {
@@ -211,7 +212,7 @@ describe('util/github/graphql/datasource-fetcher', () => {
           resp(false, [
             { version: v3, releaseTimestamp: t3, foo: '3' },
             { version: v2, releaseTimestamp: t2, foo: '2' },
-            {} as never,
+            partial<TestAdapterInput>(),
             { version: v1, releaseTimestamp: t1, foo: '1' },
           ])
         );
diff --git a/lib/util/host-rules.spec.ts b/lib/util/host-rules.spec.ts
index d8c7dbd78d..5b0c47c533 100644
--- a/lib/util/host-rules.spec.ts
+++ b/lib/util/host-rules.spec.ts
@@ -1,5 +1,4 @@
 import { NugetDatasource } from '../modules/datasource/nuget';
-import type { HostRule } from '../types';
 import {
   add,
   clear,
@@ -22,7 +21,7 @@ describe('util/host-rules', () => {
           hostType: 'azure',
           domainName: 'github.com',
           hostName: 'api.github.com',
-        } as HostRule)
+        } as never)
       ).toThrow();
     });
 
@@ -32,7 +31,7 @@ describe('util/host-rules', () => {
           hostType: 'azure',
           domainName: 'github.com',
           matchHost: 'https://api.github.com',
-        } as HostRule)
+        } as never)
       ).toThrow();
     });
 
@@ -42,7 +41,7 @@ describe('util/host-rules', () => {
           hostType: 'azure',
           hostName: 'api.github.com',
           matchHost: 'https://api.github.com',
-        } as HostRule)
+        } as never)
       ).toThrow();
     });
 
@@ -75,7 +74,7 @@ describe('util/host-rules', () => {
         username: 'root',
         password: 'p4$$w0rd',
         token: undefined,
-      } as HostRule);
+      } as never);
       expect(find({ hostType: NugetDatasource.id })).toEqual({});
       expect(
         find({ hostType: NugetDatasource.id, url: 'https://nuget.org' })
@@ -111,7 +110,7 @@ describe('util/host-rules', () => {
       add({
         domainName: 'github.com',
         token: 'def',
-      } as HostRule);
+      } as never);
       expect(
         find({ hostType: NugetDatasource.id, url: 'https://api.github.com' })
           .token
@@ -194,7 +193,7 @@ describe('util/host-rules', () => {
       add({
         hostName: 'nuget.local',
         token: 'abc',
-      } as HostRule);
+      } as never);
       expect(
         find({ hostType: NugetDatasource.id, url: 'https://nuget.local/api' })
       ).toEqual({ token: 'abc' });
@@ -313,7 +312,7 @@ describe('util/host-rules', () => {
         hostType: NugetDatasource.id,
         hostName: 'my.local.registry',
         token: 'def',
-      } as HostRule);
+      } as never);
       add({
         hostType: NugetDatasource.id,
         matchHost: 'another.local.registry',
diff --git a/lib/util/host-rules.ts b/lib/util/host-rules.ts
index 1ff39a50df..5455079219 100644
--- a/lib/util/host-rules.ts
+++ b/lib/util/host-rules.ts
@@ -125,7 +125,7 @@ export function find(search: HostRuleSearch): HostRuleSearchResult {
     logger.warn({ search }, 'Invalid hostRules search');
     return {};
   }
-  let res = {} as any as HostRule;
+  let res: HostRule = {};
   // First, apply empty rule matches
   hostRules
     .filter((rule) => isEmptyRule(rule))
diff --git a/lib/workers/repository/extract/index.spec.ts b/lib/workers/repository/extract/index.spec.ts
index ca553db297..c748146cee 100644
--- a/lib/workers/repository/extract/index.spec.ts
+++ b/lib/workers/repository/extract/index.spec.ts
@@ -1,6 +1,7 @@
-import { getConfig, mocked, scm } from '../../../../test/util';
+import { getConfig, mocked, partial, scm } from '../../../../test/util';
 import type { RenovateConfig } from '../../../config/types';
 import { logger } from '../../../logger';
+import type { PackageFile } from '../../../modules/manager/types';
 import * as _managerFiles from './manager-files';
 import { extractAllDependencies } from '.';
 
@@ -21,14 +22,18 @@ describe('workers/repository/extract/index', () => {
     });
 
     it('runs', async () => {
-      managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
+      managerFiles.getManagerPackageFiles.mockResolvedValue([
+        partial<PackageFile<Record<string, any>>>({}),
+      ]);
       const res = await extractAllDependencies(config);
       expect(Object.keys(res.packageFiles)).toContain('ansible');
     });
 
     it('skips non-enabled managers', async () => {
       config.enabledManagers = ['npm'];
-      managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
+      managerFiles.getManagerPackageFiles.mockResolvedValue([
+        partial<PackageFile<Record<string, any>>>({}),
+      ]);
       const res = await extractAllDependencies(config);
       expect(res).toMatchObject({ packageFiles: { npm: [{}] } });
     });
@@ -47,7 +52,9 @@ describe('workers/repository/extract/index', () => {
     });
 
     it('checks custom managers', async () => {
-      managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]);
+      managerFiles.getManagerPackageFiles.mockResolvedValue([
+        partial<PackageFile<Record<string, any>>>({}),
+      ]);
       config.regexManagers = [{ fileMatch: ['README'], matchStrings: [''] }];
       const res = await extractAllDependencies(config);
       expect(Object.keys(res.packageFiles)).toContain('regex');
diff --git a/lib/workers/repository/finalize/prune.spec.ts b/lib/workers/repository/finalize/prune.spec.ts
index d4bd4e880d..61d880f21f 100644
--- a/lib/workers/repository/finalize/prune.spec.ts
+++ b/lib/workers/repository/finalize/prune.spec.ts
@@ -2,10 +2,12 @@ import {
   RenovateConfig,
   getConfig,
   git,
+  partial,
   platform,
   scm,
 } from '../../../../test/util';
 import { GlobalConfig } from '../../../config/global';
+import type { Pr } from '../../../modules/platform/types';
 import * as cleanup from './prune';
 
 jest.mock('../../../util/git');
@@ -53,7 +55,7 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.findPr.mockResolvedValueOnce({ title: 'foo' } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ title: 'foo' }));
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(1);
@@ -65,9 +67,11 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.findPr.mockResolvedValueOnce({
-        title: 'foo - autoclosed',
-      } as never);
+      platform.findPr.mockResolvedValueOnce(
+        partial<Pr>({
+          title: 'foo - autoclosed',
+        })
+      );
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(1);
@@ -80,7 +84,7 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.findPr.mockResolvedValueOnce({ title: 'foo' } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ title: 'foo' }));
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(0);
@@ -93,7 +97,7 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.findPr.mockResolvedValueOnce({ title: 'foo' } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ title: 'foo' }));
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(0);
@@ -105,11 +109,9 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.getBranchPr.mockResolvedValueOnce({} as never);
+      platform.getBranchPr.mockResolvedValueOnce(partial<Pr>());
       scm.isBranchModified.mockResolvedValueOnce(true);
-      platform.findPr.mockResolvedValueOnce({
-        title: 'foo',
-      } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ title: 'foo' }));
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(0);
@@ -122,11 +124,11 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.getBranchPr.mockResolvedValueOnce({} as never);
+      platform.getBranchPr.mockResolvedValueOnce(partial<Pr>());
       scm.isBranchModified.mockResolvedValueOnce(true);
-      platform.findPr.mockResolvedValueOnce({
-        title: 'foo - abandoned',
-      } as never);
+      platform.findPr.mockResolvedValueOnce(
+        partial<Pr>({ title: 'foo - abandoned' })
+      );
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(platform.updatePr).toHaveBeenCalledTimes(0);
     });
@@ -137,9 +139,9 @@ describe('workers/repository/finalize/prune', () => {
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
-      platform.getBranchPr.mockResolvedValueOnce({} as never);
+      platform.getBranchPr.mockResolvedValueOnce(partial<Pr>());
       scm.isBranchModified.mockResolvedValueOnce(true);
-      platform.findPr.mockResolvedValueOnce({ title: 'foo' } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ title: 'foo' }));
       await cleanup.pruneStaleBranches(config, config.branchList);
       expect(git.getBranchList).toHaveBeenCalledTimes(1);
       expect(scm.deleteBranch).toHaveBeenCalledTimes(0);
diff --git a/lib/workers/repository/init/index.spec.ts b/lib/workers/repository/init/index.spec.ts
index 2c3611ee30..7681977572 100644
--- a/lib/workers/repository/init/index.spec.ts
+++ b/lib/workers/repository/init/index.spec.ts
@@ -1,4 +1,4 @@
-import { logger, mocked } from '../../../../test/util';
+import { RenovateConfig, logger, mocked, partial } from '../../../../test/util';
 import { GlobalConfig } from '../../../config/global';
 import * as _secrets from '../../../config/secrets';
 import * as _onboarding from '../onboarding/branch';
@@ -32,23 +32,27 @@ describe('workers/repository/init/index', () => {
 
   describe('initRepo', () => {
     it('runs', async () => {
-      apis.initApis.mockResolvedValue({} as never);
+      apis.initApis.mockResolvedValue(partial<_apis.WorkerPlatformConfig>());
       onboarding.checkOnboardingBranch.mockResolvedValueOnce({});
       config.getRepoConfig.mockResolvedValueOnce({});
       merge.mergeRenovateConfig.mockResolvedValueOnce({});
-      secrets.applySecretsToConfig.mockReturnValueOnce({} as never);
+      secrets.applySecretsToConfig.mockReturnValueOnce(
+        partial<RenovateConfig>()
+      );
       const renovateConfig = await initRepo({});
       expect(renovateConfig).toEqual({});
     });
 
     it('warns on unsupported options', async () => {
-      apis.initApis.mockResolvedValue({} as never);
+      apis.initApis.mockResolvedValue(partial<_apis.WorkerPlatformConfig>());
       onboarding.checkOnboardingBranch.mockResolvedValueOnce({});
       config.getRepoConfig.mockResolvedValueOnce({
         filterUnavailableUsers: true,
       });
       merge.mergeRenovateConfig.mockResolvedValueOnce({});
-      secrets.applySecretsToConfig.mockReturnValueOnce({} as never);
+      secrets.applySecretsToConfig.mockReturnValueOnce(
+        partial<RenovateConfig>()
+      );
       await initRepo({});
       expect(logger.logger.warn).toHaveBeenCalledWith(
         "Configuration option 'filterUnavailableUsers' is not supported on the current platform 'undefined'."
diff --git a/lib/workers/repository/onboarding/pr/pr-list.spec.ts b/lib/workers/repository/onboarding/pr/pr-list.spec.ts
index da2da8b985..5495856572 100644
--- a/lib/workers/repository/onboarding/pr/pr-list.spec.ts
+++ b/lib/workers/repository/onboarding/pr/pr-list.spec.ts
@@ -35,7 +35,8 @@ describe('workers/repository/onboarding/pr/pr-list', () => {
             {
               manager: 'some-manager',
               updateType: 'lockFileMaintenance',
-            } as never,
+              branchName: 'some-branch',
+            },
           ],
         },
       ];
@@ -98,7 +99,8 @@ describe('workers/repository/onboarding/pr/pr-list', () => {
               depType: 'devDependencies',
               newValue: '2.0.1',
               isLockfileUpdate: true,
-            } as never,
+              branchName: 'some-branch',
+            },
           ],
         },
       ];
diff --git a/lib/workers/repository/process/limits.spec.ts b/lib/workers/repository/process/limits.spec.ts
index 4e09fb513d..70801a7a35 100644
--- a/lib/workers/repository/process/limits.spec.ts
+++ b/lib/workers/repository/process/limits.spec.ts
@@ -2,9 +2,11 @@ import { DateTime } from 'luxon';
 import {
   RenovateConfig,
   getConfig,
+  partial,
   platform,
   scm,
 } from '../../../../test/util';
+import type { Pr } from '../../../modules/platform/types';
 import type { BranchConfig } from '../../types';
 import * as limits from './limits';
 
@@ -59,10 +61,12 @@ describe('workers/repository/process/limits', () => {
       config.prConcurrentLimit = 20;
       platform.getBranchPr.mockImplementation((branchName) =>
         branchName
-          ? Promise.resolve({
-              sourceBranch: branchName,
-              state: 'open',
-            } as never)
+          ? Promise.resolve(
+              partial<Pr>({
+                sourceBranch: branchName,
+                state: 'open',
+              })
+            )
           : Promise.reject('some error')
       );
       const branches: BranchConfig[] = [
diff --git a/lib/workers/repository/update/branch/automerge.spec.ts b/lib/workers/repository/update/branch/automerge.spec.ts
index 87bb468913..db205fbfde 100644
--- a/lib/workers/repository/update/branch/automerge.spec.ts
+++ b/lib/workers/repository/update/branch/automerge.spec.ts
@@ -1,6 +1,13 @@
-import { getConfig, git, platform, scm } from '../../../../../test/util';
+import {
+  getConfig,
+  git,
+  partial,
+  platform,
+  scm,
+} from '../../../../../test/util';
 import { GlobalConfig } from '../../../../config/global';
 import type { RenovateConfig } from '../../../../config/types';
+import type { Pr } from '../../../../modules/platform/types';
 import * as schedule from '../branch/schedule';
 import { tryBranchAutomerge } from './automerge';
 
@@ -49,7 +56,7 @@ describe('workers/repository/update/branch/automerge', () => {
     });
 
     it('returns false if PR exists', async () => {
-      platform.getBranchPr.mockResolvedValueOnce({} as never);
+      platform.getBranchPr.mockResolvedValueOnce(partial<Pr>());
       config.automerge = true;
       config.automergeType = 'branch';
       platform.getBranchStatus.mockResolvedValueOnce('green');
diff --git a/lib/workers/repository/update/branch/check-existing.spec.ts b/lib/workers/repository/update/branch/check-existing.spec.ts
index 2e1af5eef1..ff7c545d85 100644
--- a/lib/workers/repository/update/branch/check-existing.spec.ts
+++ b/lib/workers/repository/update/branch/check-existing.spec.ts
@@ -32,11 +32,13 @@ describe('workers/repository/update/branch/check-existing', () => {
     });
 
     it('returns true if first check hits', async () => {
-      platform.findPr.mockResolvedValueOnce({ number: 12 } as never);
-      platform.getPr.mockResolvedValueOnce({
-        number: 12,
-        state: 'closed',
-      } as never);
+      platform.findPr.mockResolvedValueOnce(partial<Pr>({ number: 12 }));
+      platform.getPr.mockResolvedValueOnce(
+        partial<Pr>({
+          number: 12,
+          state: 'closed',
+        })
+      );
       expect(await prAlreadyExisted(config)).toEqual({ number: 12 });
       expect(platform.findPr).toHaveBeenCalledTimes(1);
     });
diff --git a/lib/workers/repository/update/branch/get-updated.spec.ts b/lib/workers/repository/update/branch/get-updated.spec.ts
index f6ec285d2f..f1956f05db 100644
--- a/lib/workers/repository/update/branch/get-updated.spec.ts
+++ b/lib/workers/repository/update/branch/get-updated.spec.ts
@@ -110,7 +110,8 @@ describe('workers/repository/update/branch/get-updated', () => {
       config.reuseExistingBranch = true;
       config.upgrades.push({
         manager: 'npm',
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       await expect(getUpdatedPackageFiles(config)).rejects.toThrow();
     });
 
@@ -119,7 +120,8 @@ describe('workers/repository/update/branch/get-updated', () => {
       config.upgrades.push({
         packageFile: 'package.json',
         manager: 'npm',
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       npm.updateDependency.mockReturnValue('some new content');
       const res = await getUpdatedPackageFiles(config);
       expect(res).toMatchSnapshot({
@@ -173,7 +175,8 @@ describe('workers/repository/update/branch/get-updated', () => {
       config.upgrades.push({
         manager: 'composer',
         updateType: 'lockFileMaintenance',
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       composer.updateArtifacts.mockResolvedValueOnce([
         {
           file: {
@@ -200,7 +203,8 @@ describe('workers/repository/update/branch/get-updated', () => {
         manager: 'npm',
         lockFile: 'package-lock.json',
         isRemediation: true,
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       npm.updateLockedDependency.mockResolvedValueOnce({
         status: 'updated',
         files: { 'package-lock.json': 'new contents' },
@@ -222,7 +226,8 @@ describe('workers/repository/update/branch/get-updated', () => {
         manager: 'npm',
         lockFile: 'package-lock.json',
         isRemediation: true,
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       npm.updateLockedDependency.mockResolvedValueOnce({
         status: 'unsupported',
       });
@@ -241,7 +246,8 @@ describe('workers/repository/update/branch/get-updated', () => {
       config.upgrades.push({
         manager: 'npm',
         isRemediation: true,
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       config.reuseExistingBranch = true;
       git.getFile.mockResolvedValueOnce('existing content');
       npm.updateLockedDependency.mockResolvedValue({
@@ -264,7 +270,8 @@ describe('workers/repository/update/branch/get-updated', () => {
       config.upgrades.push({
         manager: 'composer',
         updateType: 'lockFileMaintenance',
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       composer.updateArtifacts.mockResolvedValueOnce([
         {
           artifactError: {
@@ -305,7 +312,8 @@ describe('workers/repository/update/branch/get-updated', () => {
         packageFile: '.gitmodules',
         manager: 'git-submodules',
         datasource: GitRefsDatasource.id,
-      } as never);
+        branchName: 'some-branch',
+      } satisfies BranchUpgradeConfig);
       gitSubmodules.updateDependency.mockResolvedValueOnce('existing content');
       const res = await getUpdatedPackageFiles(config);
       expect(res).toMatchSnapshot({
diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts
index d7a9096025..66e276a240 100644
--- a/lib/workers/repository/update/branch/index.spec.ts
+++ b/lib/workers/repository/update/branch/index.spec.ts
@@ -1550,7 +1550,8 @@ describe('workers/repository/update/branch/index', () => {
       getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce({
         updatedPackageFiles: [updatedPackageFile],
         artifactErrors: [],
-      } as never);
+        updatedArtifacts: [],
+      } satisfies PackageFilesResult);
       npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({
         artifactErrors: [],
         updatedArtifacts: [
@@ -1561,14 +1562,16 @@ describe('workers/repository/update/branch/index', () => {
         ],
       } as never);
       scm.branchExists.mockResolvedValue(true);
-      platform.getBranchPr.mockResolvedValueOnce({
-        title: 'rebase!',
-        state: 'open',
-        bodyStruct: {
-          hash: hashBody(`- [x] <!-- rebase-check -->`),
-          rebaseRequested: true,
-        },
-      } as never);
+      platform.getBranchPr.mockResolvedValueOnce(
+        partial<Pr>({
+          title: 'rebase!',
+          state: 'open',
+          bodyStruct: {
+            hash: hashBody(`- [x] <!-- rebase-check -->`),
+            rebaseRequested: true,
+          },
+        })
+      );
       scm.isBranchModified.mockResolvedValueOnce(true);
       git.getRepoStatus.mockResolvedValueOnce(
         partial<StatusResult>({
diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
index 500c1ed589..20f4492537 100644
--- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
+++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts
@@ -3,6 +3,7 @@ import { Fixtures } from '../../../../../../test/fixtures';
 import * as httpMock from '../../../../../../test/http-mock';
 import { mocked, partial } from '../../../../../../test/util';
 import * as githubGraphql from '../../../../../util/github/graphql';
+import type { GithubReleaseItem } from '../../../../../util/github/graphql/types';
 import * as _hostRules from '../../../../../util/host-rules';
 import { toBase64 } from '../../../../../util/string';
 import type { BranchUpgradeConfig } from '../../../../types';
@@ -675,7 +676,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
           url: 'https://github.com/some/other-repository/releases/other@1.0.0',
           name: 'some/dep',
           description: 'some body',
-        } as never,
+        },
         {
           version: 'other@1.0.1',
           description:
@@ -685,7 +686,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
           url: 'https://github.com/some/other-repository/releases/other@1.0.1',
           name: 'some/dep',
         },
-      ]);
+      ] satisfies GithubReleaseItem[]);
       const res = await getReleaseNotes(
         {
           ...githubProject,
diff --git a/lib/workers/repository/update/pr/participants.spec.ts b/lib/workers/repository/update/pr/participants.spec.ts
index 7d7186597e..8af8ab00d3 100644
--- a/lib/workers/repository/update/pr/participants.spec.ts
+++ b/lib/workers/repository/update/pr/participants.spec.ts
@@ -1,4 +1,4 @@
-import { mocked, platform } from '../../../../../test/util';
+import { mocked, partial, platform } from '../../../../../test/util';
 import { GlobalConfig } from '../../../../config/global';
 import type { RenovateConfig } from '../../../../config/types';
 import type { Pr } from '../../../../modules/platform/types';
@@ -21,7 +21,7 @@ describe('workers/repository/update/pr/participants', () => {
     reviewersSampleSize: null,
   } as never;
 
-  const pr: Pr = { number: 123 } as never;
+  const pr = partial<Pr>({ number: 123 });
 
   beforeEach(() => {
     GlobalConfig.reset();
diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts
index e02cf5012b..c56cb14345 100644
--- a/lib/workers/repository/updates/generate.ts
+++ b/lib/workers/repository/updates/generate.ts
@@ -359,7 +359,7 @@ export function generateBranchConfig(
         }
 
         return acc;
-      }, {} as Record<string, boolean>)
+      }, {})
     );
   }
 
-- 
GitLab