Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.typesync.org/llms.txt

Use this file to discover all available pages before exploring further.

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

bytes

Represents a Firestore bytes value.
Example:
  model: alias
  type: bytes

document-reference

Represents a Firestore document reference — a pointer to another Firestore document. Use this in place of storing a document ID as a string when you want the field to round-trip as a native reference under each Firestore SDK.
Firestore only supports storing document references in document fields, not collection references — the stored value’s path must end on a document id. The type name mirrors the SDK class DocumentReference to make this constraint obvious at the schema-definition layer.
Without an explicit model, the document-reference type intentionally does not encode the target document’s shape. If you want the generated TypeScript and Zod types to be narrowed to a specific target model, use the parameterized form below.
Example:
  model: alias
  type: document-reference

Parameterized form

document-reference also accepts an object form with an optional model field that names the target document (or alias) model. Typesync validates that the referenced model exists in the same schema and threads the target through to the generated code. The narrowing only takes effect on platforms whose Firestore SDK class is generic:
  • TypeScriptfirestore.DocumentReference<TargetModel> is emitted instead of firestore.DocumentReference<firestore.DocumentData>.
  • Zod — the inferred type from z.infer<typeof Schema> carries the same narrowed shape. The runtime instanceof check is identical for both forms — narrowing is purely at the type level.
  • Python, Swift, Security Rules — these SDK classes are not generic, so the emitted type is identical to the bare form. The schema-level validation that model resolves still runs.
Zod self-references (e.g. NoteLink.next: DocumentReference<NoteLink>) are emitted without the generic in Zod to avoid TS2456 Type alias circularly references itself on the z.infer-derived type. Pure generate-ts output is unaffected and emits the narrowed self-reference. Cross-model references narrow on both targets.
Author:
  model: document
  path: authors/{authorId}
  type:
    type: object
    fields:
      name: { type: string }

Book:
  model: document
  path: books/{bookId}
  type:
    type: object
    fields:
      title: { type: string }
      author:
        type:
          type: document-reference
          model: Author

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

Swift-specific options

Use swift.name on an object field to override only the generated Swift property name. The Firestore field name stays the same.
Example:
  model: alias
  type:
    type: object
    fields:
      class:
        type: string
        swift:
          name: userClass
struct Example: Codable {
  var userClass: String

  private enum CodingKeys: String, CodingKey {
    case userClass = "class"
  }
}

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