devtypes - v2.2.0
    Preparing search index...

    Type Alias ReplaceOne<T, K, N>

    ReplaceOne: { [P in keyof T]: P extends K ? N : T[P] }

    Replace the type of a specific property.

    Type Parameters

    • T

      The original object type

    • K extends keyof T

      The key of the property to replace

    • N

      The new type for the specified property

    Creates a new type by substituting one key with a new type. Useful for modifying specific properties without affecting the entire structure.

    type User = { id: number; name: string; email: string };
    type UpdatedUser = ReplaceOne< User, 'name', number >;
    // { id: number; name: number; email: string }