Function objectKeys

  • Returns the keys of an object as a strongly-typed array of keys.

    Type Parameters

    • T extends object

    Parameters

    • obj: T

      The object whose keys are to be extracted.

    Returns (keyof T)[]

    An array of keys of the given object, typed as the keys of the object.

    const person = { name: "Alice", age: 30 };
    const keys = objectKeys(person); // Type: ['name', 'age']