Type Alias WritablePropertyKeys<T>

WritablePropertyKeys: {
    [K in keyof T]-?: IfTypeEqual<
        { [P in K]: T[P] },
        { -readonly [P in K]: T[P] },
        K,
        never,
    >
}[keyof T]

Produces the property keys of T that support assignment.

Properties declared with readonly and getter-only accessors are excluded. Getter / setter accessors, methods, and assignable function-valued properties are included.

Type Parameters

  • T extends object

    Object type to inspect.

class Example
{
value = 1;

readonly id = 'example';

get computed(): number
{
return this.value * 2;
}

get configurable(): number
{
return this.value;
}

set configurable(value: number)
{
this.value = value;
}

reset(): void
{
this.value = 0;
}
}

type Keys = WritablePropertyKeys<Example>;
// "value" | "configurable" | "reset"