UnknownRecord ​
An object with unknown keys and unknown values.
typescript
type Data = UnknownRecord;Usage ​
UnknownRecord ​
Use it instead of {}, which accepts every non-nullish value including numbers and strings. Values are unknown, so reading one forces a check first.
typescript
import type { UnknownRecord } from 'es-toolkit/types';
function log(data: UnknownRecord) {
if (typeof data.id === 'string') {
console.log(data.id);
}
}
log({ id: '1' }); // ok
// log(42); // error, while `{}` would have allowed itType Parameters ​
- Only types with an index signature are assignable. An
interfacedeclares its keys one by one and is rejected, so acceptobjectwhen the caller may pass one, or spread it at the call site.

