devtypes
    Preparing search index...

    Type Alias Brand<Base, Tag, Key, Required>

    Brand: Base & If<
        Required,
        { readonly [K in Key]: Tag },
        { readonly [K in Key]?: Tag },
    >

    Brand a type with a unique tag to create nominal typing

    Type Parameters

    • Base
    • Tag extends string
    • Key extends string = "__brand"
    • Required extends boolean = false
    type UserID = Brand<number, 'UserID', '__userID', true>;
    const id: UserID = 123 as UserID;