// Copyright Abridged, Inc. 2021,2024. All Rights Reserved. // Node module: @collabland/common // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT /** * Optional: From `T` make a set of properties by key `K` become optional * * @example * ```ts * type Props = { * name: string; * age: number; * visible: boolean; * }; * * // Expect: { name?: string; age?: number; visible?: boolean; } * type Props = Optional; * * // Expect: { name: string; age?: number; visible?: boolean; } * type Props = Optional; * ``` * * @typeParam T - Type of the object * @typeParam K - Keys of the object */ export type Optional = Omit< T, K > & Partial>; /** * Infer element type from an array type */ export type ArrayElement = ArrayType extends readonly (infer ElementType)[] ? ElementType : never; /** * Any error for TypeScript 4.4 and beyond */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export type AnyError = any; /** * Any type for TypeScript */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export type AnyType = any;