@jossmac/lil-libs
    Preparing search index...

    Function typedFromEntries

    • Typed alternative to Object.fromEntries() that preserves output shape.

      • const Entries extends readonly (readonly [PropertyKey, unknown])[]
      • entries: Entries

        Key-value pairs to assemble into an object.

      An object whose keys and value types are inferred from the entries tuple.

      const entries = [
      ["foo", 1],
      ["bar", "hello"],
      ] as const;
      const rebuilt = typedFromEntries(entries);
      // ^? { foo: number; bar: string }