types.ts

Declarations
#

15 declarations

view source

ArrayElement
#

Assignable
#

Brand
#

Branded
#

ClassConstructor
#

types.ts view source

ClassConstructor<TInstance, TArgs>

generics

TInstance

TArgs

constraint Array<any>
default Array<any>

Defined
#

Flavor
#

Flavored
#

types.ts view source

Flavored<TValue, TName>

The Flavored and Branded type helpers add varying degrees of nominal typing to other types. This is especially useful with primitives like strings and numbers.

generics

TValue

TName

see also

  • https://spin.atomicobject.com/typescript-flexible-nominal-typing/ * Flavored is a looser form of Branded that trades explicitness and a little safety in some cases for ergonomics. With Flavored you don't need to cast unflavored types: * ``ts type Email = Flavored<string, 'Email'>; const email1: Email = 'foo'; // ok type Address = Flavored<string, 'Address'>; const email2: Email = 'foo' as Address; // error! `` * Branded requires casting: * ``ts type PhoneNumber = Branded<string, 'PhoneNumber'>; const phone1: PhoneNumber = 'foo'; // error! const phone2: PhoneNumber = 'foo' as PhoneNumber; // ok `` * See also Zod's .brand schema helper: *

KeyofUnion
#

NotNull
#

OmitStrict
#

PartialExcept
#

PartialOnly
#

PartialValues
#

PickUnion
#