Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: exactOptionalPropertyTypes #20761

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config/migrate-validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('config/migrate-validate', () => {
it('isOnboarded', async () => {
const input: RenovateConfig = {};
const res = await migrateAndValidate(
{ ...config, repoIsOnboarded: true, warnings: undefined },
{ ...config, repoIsOnboarded: true },
input
);
expect(res.warnings).toBeUndefined();
Expand Down
2 changes: 1 addition & 1 deletion lib/config/presets/gitea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function getPresetFromEndpoint(
filePreset: string,
presetPath?: string,
endpoint = Endpoint,
tag?: string
tag?: string | undefined
): Promise<Preset | undefined> {
return fetchPreset({
repo,
Expand Down
6 changes: 3 additions & 3 deletions lib/config/presets/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function fetchJSONFile(
repo: string,
fileName: string,
endpoint: string,
tag?: string | null
tag?: string | undefined
): Promise<Preset> {
let ref = '';
if (is.nonEmptyString(tag)) {
Expand Down Expand Up @@ -42,7 +42,7 @@ export function getPresetFromEndpoint(
filePreset: string,
presetPath?: string,
endpoint = Endpoint,
tag?: string
tag?: string | undefined
): Promise<Preset | undefined> {
return fetchPreset({
repo,
Expand All @@ -58,7 +58,7 @@ export function getPreset({
repo,
presetName = 'default',
presetPath,
tag = undefined,
tag,
}: PresetConfig): Promise<Preset | undefined> {
return getPresetFromEndpoint(repo, presetName, presetPath, Endpoint, tag);
}
4 changes: 2 additions & 2 deletions lib/config/presets/gitlab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function fetchJSONFile(
repo: string,
fileName: string,
endpoint: string,
tag?: string | null
tag?: string | undefined
): Promise<Preset> {
let url = endpoint;
let ref = '';
Expand Down Expand Up @@ -60,7 +60,7 @@ export function getPresetFromEndpoint(
presetName: string,
presetPath?: string,
endpoint = Endpoint,
tag?: string | null
tag?: string | undefined
): Promise<Preset | undefined> {
return fetchPreset({
repo,
Expand Down
4 changes: 2 additions & 2 deletions lib/config/presets/local/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function fetchJSONFile(
repo: string,
fileName: string,
_endpoint?: string,
tag?: string | null
tag?: string | undefined
): Promise<Preset> {
let raw: string | null;
try {
Expand All @@ -35,7 +35,7 @@ export function getPresetFromEndpoint(
filePreset: string,
presetPath: string | undefined,
endpoint: string,
tag?: string | null
tag?: string | undefined
): Promise<Preset | undefined> {
return fetchPreset({
repo,
Expand Down
16 changes: 8 additions & 8 deletions lib/config/presets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export type Preset = RenovateConfig & Record<string, unknown>;

export type PresetConfig = {
repo: string;
presetPath?: string;
presetPath?: string | undefined;
presetName?: string;
tag?: string;
tag?: string | undefined;
};

export interface PresetApi {
Expand All @@ -19,24 +19,24 @@ export interface PresetApi {
export interface ParsedPreset {
presetSource: string;
repo: string;
presetPath?: string;
presetPath?: string | undefined;
presetName: string;
tag?: string;
params?: string[];
tag?: string | undefined;
params?: string[] | undefined;
}

export type PresetFetcher = (
repo: string,
fileName: string,
endpoint: string,
tag?: string | null
tag?: string | undefined
) => Promise<Preset | null | undefined>;

export type FetchPresetConfig = {
repo: string;
filePreset: string;
presetPath?: string;
presetPath?: string | undefined;
endpoint: string;
tag?: string | null;
tag?: string | undefined;
fetch: PresetFetcher;
};
2 changes: 1 addition & 1 deletion lib/config/presets/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function fetchPreset({
filePreset,
presetPath,
endpoint: _endpoint,
tag = null,
tag,
fetch,
}: FetchPresetConfig): Promise<Preset | undefined> {
// TODO: fix me, can be undefiend #7154
Expand Down
3 changes: 2 additions & 1 deletion lib/instrumentation/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SpanKind } from '@opentelemetry/api';
import { Decorator, decorate } from '../util/decorator';
import type { SpanParameters } from './types';
import { instrument as instrumentFunc } from '.';
Expand All @@ -9,7 +10,7 @@ export function instrument<T>({
name,
attributes,
ignoreParentSpan,
kind,
kind = SpanKind.INTERNAL,
}: SpanParameters): Decorator<T> {
return decorate(async ({ callback }) => {
return await instrumentFunc(name, callback, {
Expand Down
2 changes: 1 addition & 1 deletion lib/instrumentation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface SpanParameters {
/**
* Attributes which should be added to the span
*/
attributes?: Attributes;
attributes?: Attributes | undefined;

/**
* Should this span be added to the root span or to the current active span
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export abstract class Datasource implements DatasourceApi {

defaultRegistryUrls?: string[] | (() => string[]);

defaultVersioning: string | undefined;
defaultVersioning?: string | undefined;

registryStrategy: RegistryStrategy | undefined = 'first';

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export async function getAuthHeaders(
}

async function getECRAuthToken(
region: string | undefined,
region: string,
viceice marked this conversation as resolved.
Show resolved Hide resolved
opts: HostRule
): Promise<string | null> {
const config: ECRClientConfig = { region };
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/galaxy-collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class GalaxyCollectionDatasource extends Datasource {
try {
const release: Release = {
version: basicRelease.version,
isDeprecated: basicRelease.isDeprecated,
isDeprecated: Boolean(basicRelease.isDeprecated),
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
downloadUrl: versionDetails.download_url,
newDigest: versionDetails.artifact.sha256,
dependencies: versionDetails.metadata.dependencies,
Expand All @@ -118,7 +118,7 @@ export class GalaxyCollectionDatasource extends Datasource {
// extract base information which are only provided on the release from the newest release
const result: ReleaseResult = {
releases: filteredReleases,
sourceUrl: newestVersionDetails?.metadata.repository,
sourceUrl: newestVersionDetails?.metadata.repository ?? null,
homepage: newestVersionDetails?.metadata.homepage,
tags: newestVersionDetails?.metadata.tags,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`modules/datasource/go/releases-direct getReleases support git 1`] = `
"version": "v2.0.0",
},
],
"sourceUrl": undefined,
"sourceUrl": null,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/go/releases-direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class GoDirectDatasource extends Datasource {
return null;
}

const sourceUrl = getSourceUrl(source);
const sourceUrl = getSourceUrl(source) ?? null;

/**
* github.com/org/mod/submodule should be tagged as submodule/va.b.c
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/go/releases-goproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class GoProxyDatasource extends Datasource {
const datasource = await BaseGoDatasource.getDatasource(
packageName
);
const sourceUrl = getSourceUrl(datasource);
const sourceUrl = getSourceUrl(datasource) ?? null;
result = { releases, sourceUrl };
} catch (err) {
logger.trace({ err }, `Can't get datasource for ${packageName}`);
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/golang-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class GolangVersionDatasource extends Datasource {
lines.splice(0, startOfReleases + 1);

// Parse the release list
let release: Omit<Release, 'version'> & { version?: string } = {
let release: Omit<Release, 'version'> & { version?: string | undefined } = {
version: undefined,
};
let skipFutureRelease = false;
Expand Down
16 changes: 8 additions & 8 deletions lib/modules/datasource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ export interface Release {
isStable?: boolean;
releaseTimestamp?: any;
version: string;
newDigest?: string;
newDigest?: string | undefined;
constraints?: Record<string, string[]>;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
registryUrl?: string;
sourceUrl?: string;
sourceUrl?: string | undefined;
sourceDirectory?: string;
}

export interface ReleaseResult {
deprecationMessage?: string;
isPrivate?: boolean;
releases: Release[];
tags?: Record<string, string>;
tags?: Record<string, string> | undefined;
// URL metadata
changelogUrl?: string;
dependencyUrl?: string;
homepage?: string;
homepage?: string | undefined;
gitRef?: string;
sourceUrl?: string | null;
sourceDirectory?: string;
Expand All @@ -81,16 +81,16 @@ export interface DatasourceApi extends ModuleApi {
getDigest?(config: DigestConfig, newValue?: string): Promise<string | null>;
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null>;
defaultRegistryUrls?: string[] | (() => string[]);
defaultVersioning?: string;
defaultConfig?: Record<string, unknown>;
defaultVersioning?: string | undefined;
defaultConfig?: Record<string, unknown> | undefined;

/**
* Strategy to use when multiple registryUrls are available to the datasource.
* first: only the first registryUrl will be tried and others ignored
* hunt: registryUrls will be tried in order until one returns a result
* merge: all registryUrls will be tried and the results merged if more than one returns a result
*/
registryStrategy?: RegistryStrategy;
registryStrategy?: RegistryStrategy | undefined;

/**
* Whether custom registryUrls are allowed.
Expand All @@ -102,7 +102,7 @@ export interface DatasourceApi extends ModuleApi {
* true: datasoure index wrapper should cache all results (based on registryUrl/packageName)
* false: caching is not performed, or performed within the datasource implementation
*/
caching?: boolean;
caching?: boolean | undefined;

/** optional URLs to add to docs as references */
urls?: string[];
Expand Down
1 change: 1 addition & 0 deletions lib/modules/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export type PlatformPrOptions = {
usePlatformAutomerge?: boolean;
forkModeDisallowMaintainerEdits?: boolean;
};

export interface CreatePRConfig {
sourceBranch: string;
targetBranch: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/github/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface GithubPackageConfig {
/**
* Default: https://api.github.com
*/
registryUrl?: string;
registryUrl?: string | undefined;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions lib/workers/repository/update/pr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export function getPlatformPrOptions(
);

return {
azureAutoApprove: config.azureAutoApprove,
azureWorkItemId: config.azureWorkItemId,
bbUseDefaultReviewers: config.bbUseDefaultReviewers,
gitLabIgnoreApprovals: config.gitLabIgnoreApprovals,
forkModeDisallowMaintainerEdits: config.forkModeDisallowMaintainerEdits,
azureAutoApprove: Boolean(config.azureAutoApprove),
azureWorkItemId: Number(config.azureWorkItemId),
bbUseDefaultReviewers: Boolean(config.bbUseDefaultReviewers),
gitLabIgnoreApprovals: Boolean(config.gitLabIgnoreApprovals),
forkModeDisallowMaintainerEdits: Boolean(
config.forkModeDisallowMaintainerEdits
),
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
usePlatformAutomerge,
};
}
Expand Down Expand Up @@ -385,7 +387,7 @@ export async function ensurePr(
prBody,
labels: prepareLabels(config),
platformOptions: getPlatformPrOptions(config),
draftPR: config.draftPR,
draftPR: Boolean(config.draftPR),
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
});

incLimitedValue('PullRequests');
Expand Down