WIT Types

WIT (WebAssembly Interface Types) is the interface definition language of the WebAssembly Component Model. It describes the function signatures that components export and import.

Declaring accurate types matters for two reasons:

For JS components, Obelisk synthesizes WIT interfaces from the ffqn, params, and return_type fields in deployment.toml — no WIT files needed. Rust components define their own WIT files and use the bindgen! macro to generate bindings. See JS components and Rust components for details.

WIT identifiers must use kebab-case (e.g. sleep-millis, not sleep_millis).

Primitive types

WIT typeDescription
boolBoolean
u8Unsigned 8-bit integer
u16Unsigned 16-bit integer
u32Unsigned 32-bit integer
u64Unsigned 64-bit integer
s8Signed 8-bit integer
s16Signed 16-bit integer
s32Signed 32-bit integer
s64Signed 64-bit integer
f3232-bit float
f6464-bit float
charUnicode scalar value
stringUTF-8 string

Compound types

WIT syntaxDescription
option<T>Optional value
resultSuccess/failure with no payloads
result<T>Success with value, failure with no payload
result<T, E>Success with value, failure with error
list<T>Variable-length sequence
tuple<T1, T2, ...>Fixed-length heterogeneous sequence
record { field-name: T, ... }Object with named fields
variant { case-name(T), ... }Tagged union
enum { case-name, ... }Enumeration (one of a fixed set)
flags { flag-name, ... }Bit-flag set