Type grammar
Named and generic types
Section titled “Named and generic types”Types may be named directly or qualified through a namespace:
StringGeometry.PointGeneric arguments use angle brackets in type syntax:
Array<String>Table<String, Int>Generic call arguments use doubled angle brackets so they remain distinct from comparison operators:
Array.create<<Int>>(4, 0)Optional and union types
Section titled “Optional and union types”Append ? when a value may also be nil:
String?The general union spelling joins alternatives with |:
String | Int | nilThis type union is distinct from a declared tagged union: a tagged union gives alternatives named cases and optional payloads.
Arrays and tables
Section titled “Arrays and tables”Array types have equivalent short and named forms:
{String}Array<String>Typed tables likewise have two forms:
{[String]: Int}Table<String, Int>Tuples and functions
Section titled “Tuples and functions”A tuple lists positional element types:
(String, Int, Boolean)A function type lists named parameters and an optional result:
function(value: Int): Stringfunction(message: String)Parentheses group compound types when necessary. Type spelling does not cause implicit conversions: aliases aside, values must satisfy the exact expected type or an explicitly permitted union/interface relationship.
