/* eslint-disable @typescript-eslint/no-explicit-any */ import { Nullable } from "./helpers.types"; import { JoinString } from "./string.types"; export type ObjectType = Record; export type EmptyObjectType = ObjectType; export type StringDictionary = ObjectType; export type NumericDictionary = ObjectType; export type UnionToObject = ObjectType; export type PickUnion> = keyof Pick, K>; export type OmitUnion> = keyof Omit, K>; export type PartialBy, K extends keyof T> = Omit & Partial>; export type PartialKeys> = { [K in keyof T]?: Partial; }; export type NonNullableKeys = { [P in keyof T]-?: NonNullable; }; export type NullableKeys = { [K in keyof T]: Nullable; }; export type OptionalKeys = { [K in keyof T]?: T[K]; }; type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...0[]]; export type PathsOf = [D] extends [never] ? never : T extends object ? { [K in keyof T]-?: K extends string | number ? `${K}` | JoinString, S> : never; }[keyof T] : ""; export type LeavesOf = [D] extends [never] ? never : T extends object ? { [K in keyof T]-?: JoinString, S> }[keyof T] : ""; export type ObjectPathToValue< Values extends ObjectType, P extends string, S extends string = ".", > = P extends `${infer Left}${S}${infer Rest}` ? Rest extends PathsOf ? ObjectPathToValue : never : Values[P]; export type RequiredKeys = { [K in keyof T]-?: Exclude; }; // Names of properties in T with types that include undefined export type OptionalPropertyNames = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T]; // Common properties from L and R with undefined in R[K] replaced by type in L[K] type SpreadProperties = { [P in K]: L[P] | Exclude }; // is an identity type and in principle shouldn't do anything to the type type Id = T extends infer U ? { [K in keyof U]: U[K] } : never; // Type of { ...L, ...R } export type Spread = Id< // Properties in L that don't exist in R Pick> & // Properties in R with types that exclude undefined Pick>> & // Properties in R, with types that include undefined, that don't exist in L Pick, keyof L>> & // Properties in R, with types that include undefined, that exist in L SpreadProperties & keyof L> >;