---
title: "Values and types"
description: "Contract has closed types: number, string, bool, declared records, option<T>, and T[]."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Values and types

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/learn/contract-for-humans/values-and-types: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Contract has closed types: `number`, `string`, `bool`, declared records,
`option<T>`, and `T[]`. Component interfaces can also use the bare type
`action`. There is no authored `any`, nullable field shorthand, or arbitrary
JavaScript object. The compiler infers states and derives, and a state may
declare its type (`state picked: option<Item> = none`); fields, component props,
injections, and function signatures declare theirs. A list type is written as in
TypeScript: `string[]`, `Item[]`, `option<number>[]`.

```contract
shape Fields
  title: string
  pinned: bool

component Editor
  state fields = Fields(title="Untitled", pinned=false)
  action rename(value: string)
    fields = Fields(fields, title=value)
  action pin
    fields = Fields(fields, pinned=not fields.pinned)
  view
    column gap=8
      input value=fields.title input=rename testId="title"
      button press=pin testId="pin"
        text (fields.pinned ? "Unpin" : "Pin")
```

`Fields(title=…, pinned=…)` constructs a record and must supply every field
exactly once. `Fields(fields, title=value)` copies the base and replaces named
fields. It does not mutate the base. Fields are read with `fields.title`.
Only app-declared shapes can be constructed this way; compiler-owned shapes
such as `Router` and `Geometry` come from their designated operations.

Records, lists, and options are values; equality is structural. Shape definitions
must be finite and nonrecursive. Required record fields are never defaulted by
record construction. A resource's placeholder is a separate concept.

An `option<T>` is either `none` or `some(value)`. Unwrap it explicitly:

```text
derive selected = first(items)
derive caption = match selected {
  case some(item) => item.title,
  case none => "Choose an item"
}
```

The `some` branch's binding exists only in that branch. Both arms are required.
A state initialized to `none` needs enough information elsewhere, usually an
action's assignment of `some(...)`, to infer the element type, or a declared
type (`state picked: option<Item> = none`). Actions, derives and the view all see
that type. Similarly, `[]` needs an inferable list element type. A list
literal such as `[1, 2]` holds its items, which share one type; a list the screen
keeps for the session (a selection, open ids) is built in Contract, and a list the
app keeps across launches comes from the data module.
