Skip to content

Type Constraints

Syntax

type <Name> = <BaseType>
command <Name> {
<fieldName>: <TypeName>
}

Field declarations

Fields in commands, events, and state variants use name: TypeName syntax. The type name must reference a type declared within the same context.

context Registration {
type UserId = String
type Email = String
command Register {
userId: UserId
email: Email
}
}

Compiler behavior

The compiler resolves each field’s type against the declarations in the enclosing context. Resolution happens before any semantic analysis.

Type errors are reported with file, line, and column:

Unknown type 'EmailAddress' in command Register (field: email).
Declared types in context Registration: UserId, Email, DisplayName

Scope

Type declarations are scoped to the context in which they appear. A type declared in one context is not visible in another.

Architecture decisions