1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

remove unnecessary | undefined types from the exactOptionalFieldTypes experiment

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-05-05 09:26:35 -04:00
parent a1afd425b8
commit b9ea2098b2
12 changed files with 40 additions and 43 deletions

View File

@ -93,8 +93,8 @@ export interface DeploymentSpec {
template: {
metadata: {
creationTimestamp?: string;
labels: Record<string, string | undefined>;
annotations?: Record<string, string | undefined>;
labels: Partial<Record<string, string>>;
annotations?: Partial<Record<string, string>>;
};
spec: PodSpec;
};

View File

@ -93,8 +93,8 @@ export interface HorizontalPodAutoscalerStatus {
}
interface MetricCurrentTarget {
current?: string | undefined;
target?: string | undefined;
current?: string;
target?: string;
}
export class HorizontalPodAutoscaler extends KubeObject<HorizontalPodAutoscalerStatus, HorizontalPodAutoscalerSpec, KubeObjectScope.Namespace> {

View File

@ -713,8 +713,8 @@ export interface PodSpec {
imagePullSecrets?: LocalObjectReference[];
initContainers?: PodContainer[];
nodeName?: string;
nodeSelector?: Record<string, string | undefined>;
overhead?: Record<string, string | undefined>;
nodeSelector?: Partial<Record<string, string>>;
overhead?: Partial<Record<string, string>>;
preemptionPolicy?: string;
priority?: number;
priorityClassName?: string;

View File

@ -84,7 +84,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
async getResponse<Query>(
path: string,
params?: ParamsAndQuery<Params, Query> | undefined,
params?: ParamsAndQuery<Params, Query>,
init: RequestInit = {},
): Promise<Response> {
let reqUrl = `${this.config.serverAddress}${this.config.apiBase}${path}`;
@ -110,7 +110,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
get<OutData = Data, Query = QueryParams>(
path: string,
params?: ParamsAndQuery<Params, Query> | undefined,
params?: ParamsAndQuery<Params, Query>,
reqInit: RequestInit = {},
) {
return this.request<OutData, Query>(path, params, { ...reqInit, method: "get" });
@ -118,7 +118,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
post<OutData = Data, Query = QueryParams>(
path: string,
params?: ParamsAndQuery<Params, Query> | undefined,
params?: ParamsAndQuery<Params, Query>,
reqInit: RequestInit = {},
) {
return this.request<OutData, Query>(path, params, { ...reqInit, method: "post" });
@ -126,7 +126,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
put<OutData = Data, Query = QueryParams>(
path: string,
params?: ParamsAndQuery<Params, Query> | undefined,
params?: ParamsAndQuery<Params, Query>,
reqInit: RequestInit = {},
) {
return this.request<OutData, Query>(path, params, { ...reqInit, method: "put" });
@ -134,7 +134,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
patch<OutData = Data, Query = QueryParams>(
path: string,
params?: (ParamsAndQuery<Omit<Params, "data">, Query> & { data?: Patch | PartialDeep<Data> }) | undefined,
params?: (ParamsAndQuery<Omit<Params, "data">, Query> & { data?: Patch | PartialDeep<Data> }),
reqInit: RequestInit = {},
) {
return this.request<OutData, Query>(path, params, { ...reqInit, method: "patch" });
@ -142,7 +142,7 @@ export class JsonApi<Data = JsonApiData, Params extends JsonApiParams<Data> = Js
del<OutData = Data, Query = QueryParams>(
path: string,
params?: ParamsAndQuery<Params, Query> | undefined,
params?: ParamsAndQuery<Params, Query>,
reqInit: RequestInit = {},
) {
return this.request<OutData, Query>(path, params, { ...reqInit, method: "delete" });

View File

@ -8,11 +8,11 @@
import { splitArray } from "../utils";
export interface IKubeApiLinkRef {
apiPrefix?: string | undefined;
apiPrefix?: string;
apiVersion: string;
resource: string;
name?: string | undefined;
namespace?: string | undefined;
name?: string;
namespace?: string;
}
export interface IKubeApiParsed extends IKubeApiLinkRef {

View File

@ -105,18 +105,18 @@ export interface IgnoredKubeApiOptions {
}
export interface KubeApiQueryParams {
watch?: boolean | number | undefined;
resourceVersion?: string | undefined;
timeoutSeconds?: number | undefined;
limit?: number | undefined; // doesn't work with ?watch
continue?: string | undefined; // might be used with ?limit from second request
labelSelector?: string | string[] | undefined; // restrict list of objects by their labels, e.g. labelSelector: ["label=value"]
fieldSelector?: string | string[] | undefined; // restrict list of objects by their fields, e.g. fieldSelector: "field=name"
watch?: boolean | number;
resourceVersion?: string;
timeoutSeconds?: number;
limit?: number; // doesn't work with ?watch
continue?: string; // might be used with ?limit from second request
labelSelector?: string | string[]; // restrict list of objects by their labels, e.g. labelSelector: ["label=value"]
fieldSelector?: string | string[]; // restrict list of objects by their fields, e.g. fieldSelector: "field=name"
}
export interface KubeApiListOptions {
namespace?: string | undefined;
reqInit?: RequestInit | undefined;
namespace?: string;
reqInit?: RequestInit;
}
export interface IKubePreferredVersion {
@ -268,13 +268,13 @@ export type KubeApiWatchCallback<T extends KubeJsonApiData = KubeJsonApiData> =
export interface KubeApiWatchOptions<Object extends KubeObject<any, any, KubeObjectScope>, Data extends KubeJsonApiDataFor<Object>> {
namespace: string;
callback?: KubeApiWatchCallback<Data> | undefined;
abortController?: AbortController | undefined;
watchId?: string | undefined;
retry?: boolean | undefined;
callback?: KubeApiWatchCallback<Data>;
abortController?: AbortController;
watchId?: string;
retry?: boolean;
// timeout in seconds
timeout?: number | undefined;
timeout?: number;
}
export type KubeApiPatchType = "merge" | "json" | "strategic";
@ -296,7 +296,7 @@ export interface ResourceDescriptor {
*
* Note: if not provided and the resource kind is namespaced, then this defaults to `"default"`
*/
namespace?: string | undefined;
namespace?: string;
}
export interface DeleteResourceDescriptor extends ResourceDescriptor {
@ -559,7 +559,7 @@ export class KubeApi<
return null;
}
private ensureMetadataSelfLink<T extends { selfLink?: string | undefined; namespace?: string | undefined; name: string }>(metadata: T): asserts metadata is T & { selfLink: string } {
private ensureMetadataSelfLink<T extends { selfLink?: string; namespace?: string; name: string }>(metadata: T): asserts metadata is T & { selfLink: string } {
metadata.selfLink ||= createKubeApiURL({
apiPrefix: this.apiPrefix,
apiVersion: this.apiVersionWithGroup,

View File

@ -26,13 +26,13 @@ export type OnLoadFailure = (error: unknown) => void;
export interface KubeObjectStoreLoadingParams {
namespaces: string[];
reqInit?: RequestInit | undefined;
reqInit?: RequestInit;
/**
* A function that is called when listing fails. If set then blocks errors
* being rejected with
*/
onLoadFailure?: OnLoadFailure | undefined;
onLoadFailure?: OnLoadFailure;
}
export interface KubeObjectStoreLoadAllParams {
@ -44,7 +44,7 @@ export interface KubeObjectStoreLoadAllParams {
* A function that is called when listing fails. If set then blocks errors
* being rejected with
*/
onLoadFailure?: OnLoadFailure | undefined;
onLoadFailure?: OnLoadFailure;
}
export interface KubeObjectStoreSubscribeParams {
@ -52,7 +52,7 @@ export interface KubeObjectStoreSubscribeParams {
* A function that is called when listing fails. If set then blocks errors
* being rejected with
*/
onLoadFailure?: OnLoadFailure | undefined;
onLoadFailure?: OnLoadFailure;
/**
* An optional parent abort controller

View File

@ -354,7 +354,7 @@ export interface Affinity {
}
export interface LabelSelector {
matchLabels?: Record<string, string | undefined>;
matchLabels?: Partial<Record<string, string>>;
matchExpressions?: LabelMatchExpression[];
}
@ -465,7 +465,7 @@ export class KubeObject<
);
}
static stringifyLabels(labels?: Record<string, string | undefined>): string[] {
static stringifyLabels(labels?: Partial<Record<string, string>>): string[] {
if (!labels) return [];
return Object.entries(labels).map(([name, value]) => `${name}=${value}`);

View File

@ -10,7 +10,7 @@ import searchUrlPageParamInjectable from "../input/search-url-page-param.injecta
import { KubeObject } from "../../../common/k8s-api/kube-object";
import { Badge } from "../badge";
export type GetLabelBadges = (entity: CatalogEntity, onClick?: ((evt: React.MouseEvent<any, MouseEvent>) => void) | undefined) => JSX.Element[];
export type GetLabelBadges = (entity: CatalogEntity, onClick?: (evt: React.MouseEvent<any, MouseEvent>) => void) => JSX.Element[];
const getLabelBadgesInjectable = getInjectable({
id: "get-label-badges",

View File

@ -83,7 +83,7 @@ export const isUrl = inputValidator({
*/
export const isExtensionNameInstallRegex = TypedRegEx("^(?<name>(@[-\\w]+\\/)?[-\\w]+)(@(?<version>[a-z0-9-_.]+))?$", "gi") as {
isMatch(val: string): boolean;
captures(val: string): undefined | { name: string; version?: string | undefined };
captures(val: string): undefined | { name: string; version?: string };
};
export const isExtensionNameInstall = inputValidator({

View File

@ -72,7 +72,6 @@ interface Environment {
export const getApplicationBuilder = () => {
const { rendererDi, mainDi, runSetups } = getDisForUnitTesting({
doGeneralOverrides: true,
overrideCreateStorage: false,
});
const dis = { rendererDi, mainDi };

View File

@ -2,9 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { GetRendererDiForUnitTestingOptions } from "../renderer/getDiForUnitTesting";
import { getDiForUnitTesting as getRendererDi } from "../renderer/getDiForUnitTesting";
import type { GetMainDiForUnitTestingOptions } from "../main/getDiForUnitTesting";
import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting";
import { overrideIpcBridge } from "./override-ipc-bridge";
@ -12,7 +10,7 @@ export interface GetDiForUnitTestingOptions {
doGeneralOverrides?: boolean;
}
export const getDisForUnitTesting = (opts?: GetMainDiForUnitTestingOptions & GetRendererDiForUnitTestingOptions) => {
export const getDisForUnitTesting = (opts?: GetDiForUnitTestingOptions) => {
const rendererDi = getRendererDi(opts);
const mainDi = getMainDi(opts);