devtypes - v2.0.0
    Preparing search index...

    Type Alias Mapped<Keys, T>

    Mapped: { [K in Keys]: T }

    Constructs an object whose properties keys are Keys and property values are T.

    Type Parameters

    • Keys extends string

      A string type, likely string template

    • T

      Any type that can fit into an object

    This type resembles Record, but enforces that Keys must be strings, allowing safe access to the object through string based properties.

    The reason for this is that objects are typically accessible using 'string' | 'number' | 'symbol' types, which can lead to errors when trying to iterate over object properties with a string.

    Additionally, it minimizes boilerplate code by eliminating the need to create a new type for any situation that requires a complete list of properties, ensuring excellent code completion support.

    type IsInformationPublic = Mapped< 'username' | 'email', boolean >;
    // { username: true, email: false }