ts-type-forge
    Preparing search index...

    Type Alias ExtendBrand<B, T, F>

    ExtendBrand: IsNever<F & T> extends true
        ? Brand<
            GetBrandValuePart<B>,
            T | UnwrapBrandTrueKeys<B> & string,
            F | UnwrapBrandFalseKeys<B> & string,
        >
        : never

    Extends an existing brand with additional true/false keys. Fails if the same key would be marked as both true and false.

    Type Parameters

    • B extends UnknownBrand

      The base brand to extend

    • T extends string

      Additional keys to mark as true

    • F extends string = never

      Additional keys to mark as false (defaults to never)

    Extended brand type, or never if T and F have common keys

    type Email = Brand<string, 'email'>;
    type ValidatedEmail = ExtendBrand<Email, 'validated'>;
    // ValidatedEmail has both 'email' and 'validated' as true

    type OptionalEmail = ExtendBrand<Email, 'optional', 'required'>;
    // Has 'email' and 'optional' as true, 'required' as false

    // This would return never (conflicting keys):
    // type Invalid = ExtendBrand<Email, 'verified', 'verified'>;