type-plus
    Preparing search index...

    Type Alias Properties<T>

    Properties: IsAny<
        T,
        {
            $else: IsUnknown<T, { $else: { [k in keyof T]: T[k] }; $then: T }>;
            $then: T;
        },
    >

    Extracts the property map of a type: an object type with the same keys and value types as T, preserving optional and readonly modifiers.

    • For object types: returns { [k in keyof T]: T[k] }.
    • For any and unknown: returns the input type unchanged.
    • For function types (e.g. () => void): returns {} because call signatures are not indexable; for Function, returns the interface of methods.
    • For intersections: merges properties from all branches.

    Type Parameters

    • T

      The type whose properties to extract.

    type T = { a: number; b?: string }
    type R = Properties<T> // { a: number; b?: string }

    type Merged = Properties<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }