import { PartialPossiblyUndefinedValues } from "./typeUtils.mjs"; import { NonPartial } from "./typingUtils.mjs"; //#region src/typingFnUtils.d.ts declare function asNonPartial>(obj: T): NonPartial; /** * A wrapper to Object.entries with a better typing inference * * @param obj */ declare function typedObjectEntries>(obj: T): NonNullable<{ [K in keyof T]: [K, T[K]] }[keyof T]>[]; /** * A wrapper to Object.entries with a better typing inference, but with strict * typing narrowing keys to strings. * * @param obj */ declare function strictTypedObjectEntries>(obj: T): NonNullable<{ [K in keyof T]: [K & string, T[K]] }[keyof T]>[]; /** * A wrapper to Object.keys with a better typing inference * * @param obj */ declare function typedObjectKeys>(obj: T): (keyof T)[]; /** * A safe way to cast types, use to substitute the `as Type` * * @param value */ declare function asType(value: T): T; /** * Narrow a string to a union of strings * * @param key * @param union */ declare function narrowStringToUnion(key: string | undefined | null, union: T[] | readonly T[] | Set): T | undefined; /** * Type helper to check if a type is a subtype of another type. * * @template BaseType - The base type to check against * @template SubType - The type that should extend BaseType * @returns Returns undefined, only used for type checking */ declare function typeOnRightExtendsLeftType(): unknown; /** @deprecated Use typeOnRightExtendsLeftType instead */ declare const isSubTypeOf: typeof typeOnRightExtendsLeftType; /** * Type helper to narrow a string to a key of an object. * * @param key * @param obj */ declare function isObjKey>(key: unknown, obj: T): key is keyof T; type UnionDiff = [T] extends [U] ? [U] extends [T] ? null : { onRightHasExtraErr: Exclude; } : [U] extends [T] ? { onRightHasMissingErr: Exclude; } : { onRightHasExtraErr: Exclude; onRightHasMissingErr: Exclude; }; /** * Type helper to compare two union types and determine their relationship. * * @template T - The first union type (left side) * @template U - The second union type (right side) * @param _diff - Null if unions are identical, or an object describing the * errors */ declare function unionsAreTheSame(_diff: UnionDiff): void; declare function asPartialUndefinedValues>(value: PartialPossiblyUndefinedValues): T; /** A type representing an array that is guaranteed to have at least one element. */ type NonEmptyArray = [T, ...T[]]; /** * Type guard to check if an array has at least one element. * * @param array - The array to check * @returns True if the array is non-empty, false otherwise */ declare function isNonEmptyArray(array: T[]): array is NonEmptyArray; /** * Type guard to check if an object has a specific key and narrow its type. * * @param obj - The object to check * @param key - The key to check for * @returns True if the object has the key, false otherwise */ declare function objectHasKey(obj: object, key: T): obj is object & { [K in T]: unknown }; /** * Type helper to cast a value to a type that may be undefined. Use this when * some value may have incorrectly typed as non-undefined, but you have * certainty that it can be undefined. */ declare function asPossiblyUndefined(value: T): T | undefined; //#endregion export { NonEmptyArray, asNonPartial, asPartialUndefinedValues, asPossiblyUndefined, asType, isNonEmptyArray, isObjKey, isSubTypeOf, narrowStringToUnion, objectHasKey, strictTypedObjectEntries, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };