/** * Recursively processes a tuple type and returns a union of entries. * @typeParam T - The tuple type being processed. * @typeParam I - The indices of the tuple so far, initialized to an empty array. * @typeParam R - The accumulated result, initialized to `never`. * @internal */ type TupleEntry = T extends readonly [infer Head, ...infer Tail] ? TupleEntry : R; /** * Maps an object literal to a union of literal entry pairs. * @typeParam T - The object type being processed. * @internal */ type ObjectEntry = T extends object ? { [K in keyof T]: [K, Required[K]]; }[keyof T] extends infer E ? E extends [infer K, infer V] ? K extends string | number ? [`${K}`, V] : never : never : never : never; type Entry = T extends readonly [unknown, ...unknown[]] ? TupleEntry : T extends ReadonlyArray ? [`${number}`, U] : ObjectEntry; /** * A type-preserving version of `Object.entries`. * @param obj - Any object. * @returns An array of key-value pairs with their types preserved. * * @example Immutable * ```ts * const foo2 = { a: 1, b: '✨' } as const * entries(foo2) // (['a', 1] | ['b', '✨'])[] * Object.entries(foo2) // [string, 1 | '✨'][] * ``` * * @example Mutable * ```ts * const foo1 = { a: 1, b: '✨' } * entries(foo1) // ['a', number] | ['b', string])[] * Object.entries(foo1) // [string, string | number][] * ``` */ export declare function entries(object: T): ReadonlyArray>; /** * A type-preserving version of `Object.keys`. * @param obj - Any object. * @returns An array of the keys with their types preserved. * * @example Immutable * ```ts * const foo2 = { a: 1, b: '✨' } as const * keys(foo2) // ('a' | 'b')[] * Object.keys(foo2) // string[] * ``` * * @example Mutable * ```ts * const foo1 = { a: 1, b: '✨' } * keys(foo1) // readonly ('a' | 'b')[] * Object.keys(foo1) // string[] * ``` */ export declare function keys(object: T): ReadonlyArray; /** * A type-preserving version of `Object.values`. * @param obj - Any object. * @returns An array of values with their types preserved. * * @example Immutable * ```ts * const foo2 = { a: 1, b: '✨' } as const * values(foo2) // (1 | '✨')[] * Object.values(foo2) // (1 | '✨')[] * ``` * * @example Mutable * ```ts * const foo1 = { a: 1, b: '✨' } * values(foo1) // readonly (number | string)[] * Object.values(foo1) // (number | string)[] * ``` */ export declare function values(object: T): ReadonlyArray; export {};