Component types are in the type section (7) and, for core types, the core type section
(3). This page follows design/mvp/Binary.md in the
component-model repository
(branch main, read 2026-11-18), with meanings from Text.md. The
marks 🔀 🗺️ 🔧 📝 🪙 are the specification’s gates for features outside the stable WASI 0.2 set
(see the status table). Encodings of
u32, name and vec are the core ones, on the
core module page. Component types use their own
value types, not the core ones: core value types assume a shared linear memory, component
value types describe whole values. None of them are recursive.
Core types (core type section, 3)
Each entry is a core:type, which is one core:deftype:
| Encoding | Meaning |
|---|---|
a core:rectype | A core recursive type group, as in a core type section (WebAssembly 3.0). |
00 50, vec(core typeidx), core comptype | A non-final sub type with its supertypes (WebAssembly 3.0). The 00 prefix is needed here only, see the note below. |
a core:moduletype | A core module type, below. |
Core module type
50 then vec(core:moduledecl). A module type has an initially empty type
index space. Each declaration:
| Code | Declaration | Encoding after the code |
|---|---|---|
00 | import | a core import (module name, field name, description) |
01 | type | a core rectype, encoded as in a core type section; here a non-final sub type is 50 without the 00 prefix |
02 | alias | a core alias, below |
03 | export | name, then a core externtype |
The only core alias is 10 01, u32 ct, u32 idx: an outer alias
(01) of the type sort (10, the core:sort value for type). Validation
rejects outer aliases of core module types, so while a module type is validated the core
type index space contains no module types, and module types cannot nest.
Encoding ambiguity. 50 is both the module type code and the
opcode of a non-final core sub type. In a component’s core type section a
non-final sub is therefore written 00 50; inside a module type
it is just 50. By version 1.0 the module type will get a new, non-overlapping
opcode.
Component types (type section, 7)
Each entry is a deftype, selected by its first byte:
| First byte | Kind | See |
|---|---|---|
7F down to 73, and 64 | primitive value type | below |
72, 71, 70, 6F, 6E, 6D, 6B, 6A, 69, 68, 67, 66, 65, 63 | compound value type | below |
3F | resource type | below |
40, 43 | function type | below |
41 | component type | below |
42 | instance type | below |
Type opcodes follow the same negative-SLEB128 scheme as core WebAssembly: they start at
7F (SLEB128 −1) and go down, and the non-negative SLEB128 values are reserved
for type indices. A valtype is either a type index or a primitive value type
code.
Source-read, not in the specification text: how a decoder reads a
valtype. In the wasmparser crate of wasm-tools
(crates/wasmparser/src/readers/component/types.rs, ComponentValType::from_reader,
main branch, raw, fetched 2026-11-19) the reader looks at the next byte without consuming it: if it is a
primitive value type code it consumes that one byte; otherwise it reads a signed 33-bit
LEB128 (read_var_s33) and takes it as the type index, which must fit a u32
(a negative value that is not a primitive code is an “invalid leading byte” error). So a type index is
an LEB128 whose non-negative values stay out of the range of the primitive codes. Binary.md
itself gives only the “negative codes, non-negative indices” rule above. This was read from the source
and not run on a file when the page was written. Afterwards the component viewer (2026-11-19) read 15 public
components (the jco test fixtures, wit-bindgen’s wasi-cli@0.2.0 package and a wasm-tools test
file) with this rule, a signed 33-bit LEB128 whose non-negative values are type indices, and every type index
in them resolved; a one-byte index below 0x40 was the usual case, and the viewer’s tests also
write an index of 64 and more (two bytes) by hand.
Primitive value types
| Code | Type | Values | Gate |
|---|---|---|---|
7F | bool | true and false | |
7E | s8 | integers −27 to 27−1 | |
7D | u8 | integers 0 to 28−1 | |
7C | s16 | −215 to 215−1 | |
7B | u16 | 0 to 216−1 | |
7A | s32 | −231 to 231−1 | |
79 | u32 | 0 to 232−1 | |
78 | s64 | −263 to 263−1 | |
77 | u64 | 0 to 264−1 | |
76 | f32 | IEEE 754 single, with a single NaN value | |
75 | f64 | IEEE 754 double, with a single NaN value | |
74 | char | Unicode scalar values | |
73 | string | a list of char; its memory representation is chosen by the string-encoding option | |
64 | error-context | an immutable, nondeterministic, host-defined value carrying a debug message, meant to help debugging; components must not base behaviour on its contents | 📝 |
Compound value types
| Code | Encoding after the code | Type | Validity | Gate |
|---|---|---|---|---|
72 | vec(labelvaltype) | record: named fields | at least one field | |
71 | vec(case) | variant: tagged union | at least one case | |
70 | valtype | list of the element type | ||
67 | valtype, u32 length | fixed-length list | length greater than 0 | 🔧 |
6F | vec(valtype) | tuple | at least one element | |
6E | vec(labellit) | flags: named booleans | 1 to 32 labels | |
6D | vec(labellit) | enum: one of several names | at least one label | |
6B | valtype | option | ||
6A | optional valtype (ok), optional valtype (error) | result | ||
69 | typeidx | own handle to a resource | the index must be a resource type | |
68 | typeidx | borrow handle to a resource | the index must be a resource type | |
66 | optional valtype | stream: values passed asynchronously | element may not contain a borrow; (stream char) is currently rejected | 🔀 |
65 | optional valtype | future: one value passed asynchronously | element may not contain a borrow | 🔀 |
63 | key valtype, value valtype | map | key must be bool, an integer type, char or string; value may not contain own, borrow, future, stream or error-context | 🗺️ |
The rule for an optional T? is 00 for absent or 01 then
a T. Helper encodings:
| Item | Encoding | Meaning |
|---|---|---|
| labellit | u32 length, then the label bytes | A label; length must equal the label’s byte length. Labels are kebab case, see names. |
| labelvaltype | labellit, valtype | A named field or parameter. |
| case | labellit, optional valtype, then 00 | A variant case with an optional payload. The final 00 may be reinterpreted in future as the “none” case of an optional immediate. |
| valtype | a typeidx, or a primitive type code | The index must refer to a defvaltype. |
The specialised types are defined by expansion into fundamental ones, with different codes so as to keep the author’s intent and allow other representations:
| Specialised | Despecialised |
|---|---|
| tuple of types | record with fields named “0”, “1”, … |
| flags of labels | record with one bool field per label |
| enum of labels | variant whose cases have no payload |
| option of T | variant of “none” and “some” with a T payload |
| result of T and E | variant of “ok” with an optional T and “error” with an optional E |
| string | list of char |
| map of K and V | list of tuples of K and V |
Further validation rules:
- All parameter labels, result labels, record field labels, variant case labels, flag labels and enum case labels must be strongly unique within their containing scope.
- For every defvaltype, the worst-case in-memory element size must be below 228, as defined by
elem_sizein the Canonical ABI. - A
borrowmay not occur transitively in a function’s result type, nor in an exported value type. - Own and borrow handles are lifted and lowered as
i32indexes into a per-instance table;ownis destroyed when dropped; aborrowmust be dropped before the current export call returns. - A
mapmay contain duplicate keys; tools may deduplicate them provided the last pair for a key decides its value.
Resource type
3F, a core:valtype (the representation), then an optional
core:funcidx (the destructor): 00 for none, or 01 and a
function index. Each instance of the containing component gets a fresh, distinct resource
type. The representation is, in the current text format, i32, or i64 with
the 🐘 gate. When the last handle is dropped the destructor is called if present. Its type
must be [i32] -> [] (Binary.md), written in Text.md as
($T) -> () for a representation $T. Resource types may not be defined
inside component or instance types, so a resource type in one of those can only come from an
import or export.
Function type
| Code | Encoding | Meaning |
|---|---|---|
40 | paramlist, resultlist | A synchronous function. |
43 | paramlist, resultlist | An async function: calling it may block. Binary.md marks this production with no gate, but it is the async effect of the 🔀 concurrency feature. |
| Item | Encoding |
|---|---|
| paramlist | vec(labelvaltype): each parameter has a name and a type |
| resultlist | 00 then a valtype: one result; or 01 00: no result |
Parameter names must be strongly unique, and a borrow may not occur anywhere
in the result type. The two function codes are to be merged into one with an optional
immediate in version 1.0.
Component type
41, then vec(componentdecl). It describes the imports and exports of a
component. Each declaration:
| Code | Declaration | Encoding after the code |
|---|---|---|
03 | import | nameattributes, externtype (only in component types) |
00 | core type | a core:type |
01 | type | a type |
02 | alias | an alias |
04 | export | nameattributes, externtype |
Codes 00, 01, 02 and 04 are the
instance declarations; a component type allows these and also 03.
Instance type
42, then vec(instancedecl), where each instance declaration is one of the four
above (00 core type, 01 type, 02 alias,
04 export). An instance type is a static interface description. In both
component and instance types:
- The type index space starts empty. Outer aliases can bring in types from the containing scopes.
- Alias declarations: export aliases may only alias the instance and type sorts; outer aliases only the core type and type sorts.
- An export declaration introduces a new type index for later definitions. With an
eqbound the new index is an alias of the given type; withsub resourceit is a fresh abstract type unequal to every existing type. - Resource types may not be defined directly in these types.
- The attributes in a declaration’s nameattributes are ignored when validating the types of components and instances.
Extern types (what an import or export carries)
| Encoding | Kind | Meaning | Gate |
|---|---|---|---|
00 11, core typeidx | core module | a core module of that core module type | |
01, typeidx | func | a function of that function type | |
02, valuebound | value | a value of that bound | 🪙 |
03, typebound | type | a type, with a bound | |
04, typeidx | component | a component of that component type | |
05, typeidx | instance | an instance of that instance type |
The typeidx of each case must match the preceding sort: for example case 04
needs a component type. In 00 11 the 00 is the core prefix of a sort
and 11 the core module sort.
| typebound | Meaning |
|---|---|
00, typeidx | (eq i): the type is structurally equal to a preceding type. It allows an imported abstract type to be re-exported, another label for an abstract type, and a transparent alias for a structural type. |
01 | (sub resource): an abstract type that is a subtype of “any resource type”. Only resource types can be imported or exported abstractly. |
| valuebound 🪙 | Meaning |
|---|---|
00, valueidx | (eq i): the value is exactly the value at that index; this is the inferred bound of an exported value, and it makes the constant part of the component’s type. |
01, valtype | any value of that type |
Sources
design/mvp/Binary.md (“Type Definitions” and its notes) and
design/mvp/Text.md (“Type Definitions”, “Fundamental value types”,
“Specialized value types”, “Definition types”, “Declarators”, “Alias Definitions”) in
github.com/WebAssembly/component-model,
raw files read 2026-11-18.