Here, you’ll find a comprehensive list of all types supported by the Typesync specification. Typesync’s powerful type system is designed to support a wide array of complex and useful types.

any

Represents any type.

Example:
  model: alias
  type: any

unknown

Represents an unknown type.

Example:
  model: alias
  type: unknown

nil

Represents the explicit absence of a value.

Example:
  model: alias
  type: nil

string

Represents a string value.

Example:
  model: alias
  type: string

boolean

Represents a boolean value.

Example:
  model: alias
  type: boolean

int

Represents a signed integer.

Example:
  model: alias
  type: int

double

Represents a double-precision floating point number.

Example:
  model: alias
  type: double

timestamp

Represents a datetime value.

Example:
  model: alias
  type: timestamp

literal

Represents a literal type.

Literal types are not supported in Swift. Typesync currently compiles literal types to the type of the literal value in Swift.

MeaningOfLife:
  model: alias
  type:
    type: literal
    value: 42

enum

Represents an enum value.

UserRole:
  model: alias
  docs: Represents a user's role within a project.
  type:
    type: enum
    members:
      - label: Owner
        value: owner
      - label: Admin
        value: admin
      - label: Member
        value: member

tuple

Represents a tuple value.

Example:
  model: alias
  type:
    type: tuple
    elements:
      - string
      - boolean
      - int

list

Represents a list of items.

Example:
  model: alias
  type:
    type: list
    elementType: string

map

Represents a mapping from arbitrary strings to values of any type.

Example:
  model: alias
  type:
    type: map
    valueType: int

object

Represents an object with known fields.

Example:
  model: alias
  type:
    type: object
    fields:
      name:
        type: string
      completed:
        type: boolean
      github_url:
        type: string
        optional: true

union

Represents a union of multiple types. Typesync supports two types of unions: simple union and discriminated union. Both are defined in the same way using variants, except a discriminated union definition has a discriminant key and requires every variant to be of object (or alias resolving to object) type.

Simple Union Example

Path:
  model: alias
  type:
    type: union
    variants:
      - string
      - type: list
        elementType: string

Discriminated Union Example

Cat:
  model: alias
  type:
    type: object
    fields:
      type:
        type:
          type: literal
          value: cat
      name:
        type: string
      lives_left:
        type: int

Dog:
  model: alias
  type:
    type: object
    fields:
      type:
        type:
          type: literal
          value: dog
      name:
        type: string
      breed:
        type: string

Pet:
  model: alias
  type:
    type: union
    discriminant: type
    variants:
      - Cat
      - Dog

alias

Represents an alias of another type.

User:
  model: alias
  type:
    type: object
    fields:
      name_first:
        type: string
      name_last:
        type: string

WorkspaceMember:
  model: alias
  type: User