ts-type-forge
    Preparing search index...

    Type Alias ChangeBaseBrand<B, T>

    ChangeBaseBrand: Brand<
        T,
        UnwrapBrandTrueKeys<B> & string,
        UnwrapBrandFalseKeys<B> & string,
    >

    Changes the underlying value type of a brand while preserving all brand keys.

    Type Parameters

    • B extends UnknownBrand

      The brand whose keys to preserve

    • T

      The new underlying value type

    Brand with same keys but different underlying type

    type UserId = Brand<string, 'UserId' | 'validated'>;
    type NumericUserId = ChangeBaseBrand<UserId, number>;
    // NumericUserId is Brand<number, 'UserId' | 'validated'>

    // Useful for type conversions
    type SerializedData = Brand<string, 'json' | 'validated'>;
    type ParsedData = ChangeBaseBrand<SerializedData, object>;