type alias Brand

Represents a type that is branded with a unique symbol.

Useful for creating types that are unique to your application.

Examples

Example 1

type Seconds = Brand<number, 'Seconds'>;
type Milliseconds = Brand<number, 'Milliseconds'>;

function secondsToMilliseconds(seconds: Seconds): Milliseconds {
  return seconds * 1000;
}

Type Parameters

Definition

T & { __brand: B; }

Usage

import { type Brand } from ".";