Function getKnownPropertyNames

  • Object.getOwnPropertyNames() is intentionally generic: it returns the immediate property names of an object, but it cannot make guarantees about the contents of that object, so the type of the property names is merely string[]. While this is technically accurate, it is also unnecessary if we have an object with a type that we own (such as an enum).

    Returns

    The own property names of the object which are assigned a type derived from the object itself.

    Type Parameters

    • Key extends PropertyKey

    Parameters

    • object: Partial<Record<Key, any>>

      The plain object.

    Returns Key[]