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]
[K in keyof T]-?: IfTypeEqual<
{ [P in K]: T[P] },
{ -readonly [P in K]: T[P] },
K,
never,
>
}[keyof T]
Type Parameters
- T extends object
Object type to inspect.
Example
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"
Produces the property keys of
Tthat support assignment.Properties declared with
readonlyand getter-only accessors are excluded. Getter / setter accessors, methods, and assignable function-valued properties are included.