tsafe
GitHub
  • 👋What is tsafe?
  • ⚙️How to import
  • assert
  • Equals
  • id
  • is
  • objectKeys
  • exclude
  • isAmong
  • symToStr
  • ReturnType
  • Parameters
  • Param0
  • typeGuard
  • capitalize/uncapitalize
  • MethodNames
  • isPromiseLike
  • flip
  • objectEntries
  • objectFromEntries
  • UnionToIntersection
  • 🚧withDefaults
  • 📉UnpackPromise
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

objectEntries

Like Object.entries() but with a better return type.

PreviousflipNextobjectFromEntries

Last updated 6 months ago

Was this helpful?

Functionally equal to Object.entries but features a return type more precise than just [string, T][].

import { assert, type Equals, objectEntries } from "tsafe";

//    v entries is of type ["a", string], ["b", number], ["c", boolean]
const entries = objectEntries({
	a: "foo",
	b: 33,
	c: true,
});

assert<
	Equals<typeof entries, (["a", string] | ["b", number] | ["c", boolean])[]>
>();

WARNING: .

See objectKeys()'s warning