Type Alias $Type<T, V, $O>

$Type: $O extends { bare: true }
    ? $Type.$<T, V>
    : [V] extends [null] | [undefined] | [symbol] | [void]
        ? $Type.$<T, V>
        : $Type.$<T, V> & V

A branded type to define unique types for type-level programming.

It supports all primitive types and object types.

When using object types, the type intersect with the specified type to give easy access to its properties.

Internally, it uses the properties _$type and _$value to store the type and value. The type you provide should avoid specifying these properties.

If needed, use $O: { bare: true } to avoid the intersection.

Type Parameters

  • T extends string
  • V = unknown
  • $O extends { bare: true } | unknown = unknown

8.0.0