Function: typedObjectValues()
typedObjectValues<
T
>(obj
:T
):T
[keyofT
][]
Defined in: shared/utils/objectSafety.ts:276
Type-safe Object.values that preserves value types for known object shapes.
Type Parametersโ
Tโ
T
extends Record
<PropertyKey
, unknown
>
Parametersโ
objโ
T
Object to get values from
Returnsโ
T
[keyof T
][]
Array of values with proper typing
Remarksโ
This function uses type assertion to preserve compile-time type information. Object.values() only returns enumerable property values, so non-enumerable properties and symbol-keyed properties are not included. The cast assumes all values are of type T[keyof T], which is accurate for the enumerable properties that Object.values() actually returns.
Exampleโ
const config = { timeout: 5000, retries: 3 } as const;
const values = typedObjectValues(config);
// Type: number[]