Types Reference
Primitive Types
Section titled “Primitive Types”| Type | Description | Examples |
|---|---|---|
text | String value | "hello", 'world' |
number | Numeric value | 42, -3.14 |
boolean | Boolean value | true, false |
json | Object or array | { key: "value" } |
prompt | Prompt string | Same as text |
null | Null value | null |
Special Types
Section titled “Special Types”| Type | Description |
|---|---|
model | AI model configuration (always immutable) |
Named Structural Types
Section titled “Named Structural Types”Define custom types with the type keyword:
type Result { valid: boolean message: text count: number}Type Declaration Syntax
Section titled “Type Declaration Syntax”type TypeName { fieldName: fieldType // ... more fields}Fields can be separated by commas, newlines, or both:
// Comma-separatedtype Point { x: number, y: number }
// Newline-separatedtype Config { timeout: number retries: number}
// Mixedtype Mixed { a: text, b: number c: boolean}Nested Types
Section titled “Nested Types”Reference other types or use inline nested objects:
type Inner { value: number }
type Outer { inner: Inner // Reference named type metadata: { // Inline nested object timestamp: number source: text }}Arrays of Structural Types
Section titled “Arrays of Structural Types”type Player { name: text, score: number }type Team { players: Player[] }
let team: Team = do "Create a team with 3 players" modelType Usage
Section titled “Type Usage”Use named types in:
// Variable declarationslet result: Result = do "Validate input" model
// Function parametersfunction process(data: Result): text { return data.message}
// Function return typesfunction check(): Result { return { valid: true, message: "OK", count: 1 }}
// Arrayslet results: Result[] = []Member Access Type Resolution
Section titled “Member Access Type Resolution”Accessing fields on typed variables returns the field’s type:
type Status { active: boolean, count: number }let s: Status = do "Get status" model
// s.active is boolean (can use in if conditions)if s.active { print("Active")}
// s.count is numberlet doubled = s.count * 2Array Types
Section titled “Array Types”Append [] to any type:
| Type | Description |
|---|---|
text[] | Array of strings |
number[] | Array of numbers |
boolean[] | Array of booleans |
json[] | Array of objects |
Nested Arrays
Section titled “Nested Arrays”let matrix: number[][] = [[1, 2], [3, 4]]let nested: text[][][] = [[["a", "b"]], [["c"]]]Type Annotations
Section titled “Type Annotations”Variable Declarations
Section titled “Variable Declarations”let name: text = "Alice"let age: number = 30let active: boolean = truelet config: json = { timeout: 5000 }let items: text[] = ["a", "b", "c"]Function Parameters
Section titled “Function Parameters”function greet(name: text, times: number): text { // ...}Return Types
Section titled “Return Types”function getItems(): text[] { return ["a", "b", "c"]}
function getConfig(): json { return { key: "value" }}Type Inference
Section titled “Type Inference”Types are inferred when not specified:
let name = "Alice" // textlet count = 42 // numberlet active = true // booleanlet items = [1, 2, 3] // number[]let config = { a: 1 } // jsonAI Return Types
Section titled “AI Return Types”Specify return type for AI expressions:
// Without type - returns textlet result = do "How many?"
// With type - returns parsed valuelet count: number = do "How many planets?"let valid: boolean = do "Is this correct?"let items: text[] = do "List 5 items"let data: json = do "Return structured data"Null Type
Section titled “Null Type”Variables can hold null:
let maybe: text = nulllet result = nullType Compatibility
Section titled “Type Compatibility”Text and Prompt
Section titled “Text and Prompt”text and prompt are interchangeable:
let message: text = "Hello"let prompt: prompt = message // OKJSON Flexibility
Section titled “JSON Flexibility”json accepts objects and arrays:
let obj: json = { name: "Alice" }let arr: json = [1, 2, 3]let nested: json = { items: [1, 2, 3] }Model Type
Section titled “Model Type”Models are always const:
model myModel = { name: "claude-sonnet-4-20250514", provider: "anthropic", apiKey: env("API_KEY")}
// Cannot reassign// myModel = { ... } // ErrorType Coercion
Section titled “Type Coercion”Vibe does not perform automatic type coercion:
let num = 42let str = "The answer is: "
// Must explicitly convertlet message = str + num // Error: cannot add text and number
// Use ts block for conversionlet message = ts(str, num) { return str + num.toString();}Type Checking in Conditions
Section titled “Type Checking in Conditions”Conditions must be boolean:
let count = 5
// This worksif count > 0 { }if count == 0 { }
// This does NOT work// if count { } // Error: condition must be boolean// if "string" { } // Error