Library API
    Preparing search index...

    Function Branded

    • Attaches a brand symbol to a class prototype, ensures Symbol.toStringTag is set, and provides static is<ClassName>() and [Symbol.hasInstance] checking.

      Supports direct use as @Branded and configured use as @Branded(), @Branded('CustomName'), or @Branded(mySymbol, 'CustomName').

      Type Parameters

      Parameters

      • OptionalbrandOrValue: string | symbol | T

        A custom symbol, string name, or the class constructor when used directly.

      • OptionalnameOrContext: string | ClassDecoratorContext<T>

        A custom name string, or the decorator context when used directly.

      Returns any

      The decorated class or a decorator factory that applies the brand.

      @Branded
      class Pledge<T> { ... }

      Pledge.isPledge(p); // true
      p instanceof Pledge; // true