diff --git a/lib/config/migrations/custom/dep-types-migration.ts b/lib/config/migrations/custom/dep-types-migration.ts index f7a824729b69c3263ad0b819cae446f3cb229605..621c32413f62aae3ff2c40402d22bc04b34147a1 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 6d1ffb0558b793d2912e03f37d7ec06c6dea0274..15ed77dbad2c78a5dce4ed1a5188611228d8f3d5 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 da163cb0ea70e0ad06a33432fb6017739bac9a77..3c0720d019a2543e43fe28ba9962898fb0197453 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 025503c35edcfa2d440561d6dd4cf66ee24abf1c..46b971dd027ee1af1bb684447bdb84cb5a108a0b 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 ac8bfb824d15f8ca3e37f9773b7ae44c4a402ae1..bad712dfd8b194e73c402ecdb18dc7bd87bfb944 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 def6948ea10b12ca96b081a5331f0b68d5701c02..a3e0f0d6dbdf19849610bb25202fe67072d02ab5 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 4b61916037cf344207c62609331a356f0e5b547d..a306b76a7bf4aaa32f185085f343773cfcf1c498 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 ba40d4a3aa12fbfc329772c750592b3bec6448be..3714876461c9864009e14cddcf3a5017f544d6bb 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 cdbfade27138d0bedff6a1ade2b971825ee45cbc..3542031c09851ad65de8a0d112d39ea4502f20e2 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 34aae3e8d02a3a50a587a07ddd44f5df2fb1aae3..f28e053ad810952cba2c8c22dcc2b3a4c0af3013 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 082d9bad32d392604cac19e78ed08f88cf66faad..bed035a5643e1b068cced25050462ee860d76e01 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 d8c7dbd78ddf4a41f7fb0b8e86ae180fa3b2df24..5b0c47c5337099c950233c12efd741eae30b2556 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 1ff39a50df6d41fb8e494c3c914c0b702e6cb20c..5455079219f45b323dfc333cdef52760e1f3bad2 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 ca553db29719518ca7b586e6148e98bdb541c08e..c748146cee26e121dc3957f003acefeaebaabcbb 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 d4bd4e880dd30e4652ccfe9f80e5d97d7650cf08..61d880f21f31ef3822b3c0bb3145be06c8d42c31 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 2c3611ee30b20c3844db6d27eba2d849730e99b9..7681977572d679f23b0ae91bb3ff3d98cfbcd394 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 da2da8b9858fc6f5ee8636ead33c98b7c8b1f128..54958565721f423586243390e4ba4c85874ff2fc 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 4e09fb513daee022712d0034e2d057ccd0a471f6..70801a7a35df00270913a61c782abdfb8649caa5 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 87bb468913a999e6a4fb14635d7cbc7e0b996129..db205fbfde8f5250fd3f587c8093c0cc2a1bf55d 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 2e1af5eef1a7cd4711792f7b2e789966f42bc577..ff7c545d85a5708398be0a269f4020edd5751315 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 f6ec285d2f4a0ee40285dd2d14a6f40f01c706e1..f1956f05db09d9910cebceb6881222f83471b8a0 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 d7a909602525862bb9f30fe5e8d7ae83e4f79517..66e276a240c3afdedfac19565de47c019e03c20e 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 500c1ed58936bca4a778e4a2b0068a4fca2661b4..20f4492537e1483a924a106c616fffee638f4d7a 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 7d7186597e07bb7f08ec85cd54f08fc0c08c5cbf..8af8ab00d33d7de77ae293e8408e2f1117090826 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 e02cf5012b7c20297fbcca9e54fbe888af3ac12a..c56cb1434567d6f4b76fc4afe500e5fc44789d23 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>) + }, {}) ); }