/** * TypeScript-specific helper utilities * These are enhanced utilities for better TypeScript support */ /** * Type guard that filters out null and undefined values. * This is a TypeScript-specific utility beyond standard Lodash. * * @param value - The value to check * @returns Returns true if value is not null or undefined * * @example * const values = [1, null, 2, undefined, 3]; * const nonNullable = values.filter(isNonNullable); * // => [1, 2, 3] * // Type is number[] */ export declare function isNonNullable(value: T): value is NonNullable; /** * Type assertion function that throws if value doesn't match the predicate. * This is a TypeScript-specific utility beyond standard Lodash. * * @param value - The value to assert * @param predicate - The predicate function * @param message - Optional error message * @throws {TypeError} Throws if predicate returns false * * @example * function processString(value: unknown) { * assertType(value, isString, 'Expected string'); * // value is now typed as string * return value.toUpperCase(); * } */ export declare function assertType(value: T, predicate: (value: T) => value is U, message?: string): asserts value is U; /** * Narrows the type of a value using a type guard. * This is a TypeScript-specific utility beyond standard Lodash. * * @param value - The value to narrow * @param predicate - The type guard function * @returns Returns the value with narrowed type or undefined * * @example * function processValue(value: string | number) { * const str = narrowType(value, isString); * if (str) { * // str is typed as string * return str.toUpperCase(); * } * return value.toString(); * } */ export declare function narrowType(value: T, predicate: (value: T) => value is U): U | undefined; /** * Creates a type-safe property accessor function. * This is a TypeScript-specific utility beyond standard Lodash. * * @param obj - The object to create accessor for * @returns Returns a type-safe property accessor * * @example * const user = { name: 'John', age: 30 }; * const accessor = createAccessor(user); * const name = accessor('name'); // Type: string * const age = accessor('age'); // Type: number */ export declare function createAccessor>(obj: T): (key: K) => T[K]; /** * Type-safe key extraction for objects. * This is a TypeScript-specific utility beyond standard Lodash. * * @param obj - The object to extract keys from * @returns Returns typed keys array * * @example * const user = { name: 'John', age: 30 }; * const keys = typedKeys(user); // Type: ('name' | 'age')[] */ export declare function typedKeys>(obj: T): Array; /** * Type-safe value extraction for objects. * This is a TypeScript-specific utility beyond standard Lodash. * * @param obj - The object to extract values from * @returns Returns typed values array * * @example * const user = { name: 'John', age: 30 }; * const values = typedValues(user); // Type: (string | number)[] */ export declare function typedValues>(obj: T): Array; /** * Type-safe entries extraction for objects. * This is a TypeScript-specific utility beyond standard Lodash. * * @param obj - The object to extract entries from * @returns Returns typed entries array * * @example * const user = { name: 'John', age: 30 }; * const entries = typedEntries(user); // Type: [keyof typeof user, string | number][] */ export declare function typedEntries>(obj: T): Array<[keyof T, T[keyof T]]>; /** * Creates a discriminated union type guard. * This is a TypeScript-specific utility beyond standard Lodash. * * @param discriminant - The discriminant property name * @param value - The discriminant value to check for * @returns Returns a type guard function * * @example * type Shape = * | { type: 'circle'; radius: number } * | { type: 'rectangle'; width: number; height: number }; * * const isCircle = createDiscriminantGuard('type', 'circle'); * * function getArea(shape: Shape): number { * if (isCircle(shape)) { * // shape is typed as { type: 'circle'; radius: number } * return Math.PI * shape.radius ** 2; * } * // shape is typed as { type: 'rectangle'; width: number; height: number } * return shape.width * shape.height; * } */ export declare function createDiscriminantGuard(discriminant: K, value: V): (obj: T) => obj is T & Record; /** * Type-safe array filtering that removes falsy values. * This is a TypeScript-specific utility beyond standard Lodash. * * @param array - The array to filter * @returns Returns array with falsy values removed * * @example * const values = [1, 0, 'hello', '', null, undefined, false, true]; * const truthy = filterTruthy(values); * // => [1, 'hello', true] * // Type: (string | number | boolean)[] */ export declare function filterTruthy(array: readonly T[]): Array>; /** * Creates a type-safe partial object with specific keys. * This is a TypeScript-specific utility beyond standard Lodash. * * @param obj - The source object * @param keys - The keys to include * @returns Returns partial object with specified keys * * @example * const user = { id: 1, name: 'John', age: 30, email: 'john@example.com' }; * const partial = createPartial(user, ['name', 'email']); * // Type: { name: string; email: string; } */ export declare function createPartial(obj: T, keys: readonly K[]): Pick;