kinetex - v1.0.0-rc.1
    Preparing search index...

    Type Alias Brand<T, B>

    Brand: T & { __brand: B }

    Branded type utility — creates a nominal subtype.

    Use to prevent accidental mixing of semantically different values that share the same underlying type.

    Type Parameters

    • T
    • B extends string

    Type Declaration

    • Readonly__brand: B

      Brand discriminator — prevents accidental mixing of semantically different values that share the same underlying type.

    type UserId  = Brand<string, "UserId">;
    type OrderId = Brand<number, "OrderId">;

    function getUser(id: UserId) { /* ... *&#47; }
    getUser("abc" as UserId); // OK
    getUser(123 as unknown as UserId); // Error