Skip to content

Type

Syntax

type <Name> = <BaseType>
type <Name> = <BaseType>[]

Type declarations create named aliases for base types. The optional [] suffix denotes an array type.

Purpose

Types map domain vocabulary to implementation types. Domain experts write UserId and Email; the compiler maps these to platform types during code generation.

Array Types

Append [] to create an array type:

type ItemList = Item[]
type Tags = String[]

Scope

Type declarations are scoped to their enclosing context. A type declared in one context is not visible in another.

Example

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

Compiler Checks

Type references are resolved by Langium’s linker. An unresolved type reference produces a diagnostic at the reference site.