Type Alias ReadonlyProperties<T>

ReadonlyProperties: Pick<T, ReadonlyPropertyKeys<T>>

Projects T to an object containing only its readonly properties.

Explicit readonly modifiers, getter-only accessors, optional modifiers, and property value types are preserved.

Type Parameters

  • T extends object

    Object type to project.

interface Example
{
value: number;
readonly id: string;
readonly created?: Date;
}

type Result = ReadonlyProperties<Example>;

// {
// readonly id: string;
// readonly created?: Date;
// }