Aexol supports advanced type system features including array types, circular references, and multi-dimensional arrays for building complex data structures.
Define arrays of any type using the [] notation. Arrays can be
single-dimensional or multi-dimensional.
type User {
id: string
name: string
email: string
tags: string[] // Array of strings
profileImages: string[] // Another array
}
type BlogPost {
id: string
title: string
authorId: string
tags: string[] // Array of strings
relatedPostIds: string[] // Array of post IDs
}
✨ Edit in Studiotype Comment {
id: string
text: string
authorId: string
}
type Post {
id: string
title: string
content: string
comments: Comment[] // Array of Comment objects
likes: string[]
}
type User {
id: string
name: string
posts: Post[] // Array of Post objects
}
✨ Edit in StudioUse multiple [] to create multi-dimensional arrays, perfect for matrices and
nested data structures:
type Matrix {
id: string
name: string
data: number[][] // 2D array (matrix)
labels: string[]
}
type Tensor {
id: string
values: number[][][] // 3D array
}
type Dataset {
id: string
matrices: Matrix[] // Array of Matrix objects
metadata: string[]
}
✨ Edit in StudioAexol supports circular references, allowing types to reference themselves or each other. This is essential for modeling real-world relationships like social networks, organizational hierarchies, and linked data structures.
Create recursive data structures by having a type reference itself:
type TreeNode {
id: string
value: string
parent: TreeNode // Reference to parent node
children: TreeNode[] // Array of child nodes
}
type Category {
id: string
name: string
parentCategory: Category // Self-reference
subcategories: Category[] // Array of subcategories
}
✨ Edit in StudioTypes can reference each other, creating bidirectional relationships:
type User {
id: string
name: string
email: string
posts: Post[] // User references Post
comments: Comment[] // User references Comment
}
type Post {
id: string
title: string
content: string
author: User // Post references User back
comments: Comment[] // Post references Comment
}
type Comment {
id: string
text: string
author: User // Comment references User
post: Post // Comment references Post back
}
✨ Edit in StudioBuild sophisticated data models with multiple circular references:
type Organization {
id: string
name: string
departments: Department[]
employees: Employee[]
}
type Department {
id: string
name: string
organization: Organization // Back reference
employees: Employee[]
manager: Employee
}
type Employee {
id: string
name: string
department: Department // Reference to department
organization: Organization // Reference to organization
directReports: Employee[] // Self-reference for hierarchy
manager: Employee // Self-reference for reporting
}
✨ Edit in StudioAexol generates type-safe code from your type definitions in TypeScript, Python, Rust, Go, and JavaScript. Arrays become language-native collections, circular references use forward declarations, and multi-dimensional arrays map to nested collections.
Example output — type User { tags: string[]; posts: Post[] } becomes:
tags: string[] — native array typetags: List[str] — from __future__ import annotations handles
circular refstags: Vec<String> — Vec for arraystags []string — slice typeUse Studio or the Remote MCP endpoint to generate code from any Aexol spec.
type Playlist {
id: string
name: string
trackIds: string[] // ✓ Good: Clear collection
tags: string[]
}
✨ Edit in Studiotype Book {
id: string
title: string
author: Author
chapters: Chapter[] // ✓ Good: Natural relationship
}
type Author {
id: string
name: string
books: Book[] // ✓ Good: Bidirectional relationship
}
✨ Edit in Studiotype Image {
id: string
pixels: number[][] // ✓ Good: 2D pixel data
width: number
height: number
}
type GameBoard {
id: string
cells: string[][] // ✓ Good: 2D grid
}
✨ Edit in StudioWhen using circular references, consider adding comments to clarify relationships:
type User {
id: string
posts: Post[] // User's authored posts
}
type Post {
id: string
author: User // Post's author (circular ref)
}
✨ Edit in StudiofieldName: TypeName[] // Single-dimensional array
fieldName: TypeName[][] // Two-dimensional array
fieldName: TypeName[][][] // Three-dimensional array
✨ Edit in Studiostring[], number[], boolean[], datetime[]User[], Post[], Comment[]Status[], Role[]string[][], User[][]type User {
id: string
username: string
email: string
followers: User[] // Array of users following this user
following: User[] // Array of users this user follows
posts: Post[]
likes: Post[]
}
type Post {
id: string
content: string
author: User // Circular reference to User
likedBy: User[] // Array of users who liked this
comments: Comment[]
}
type Comment {
id: string
text: string
author: User // Reference to User
post: Post // Reference to Post
}
✨ Edit in Studiotype File {
id: string
name: string
content: string
parent: Directory // Reference to parent directory
tags: string[]
}
type Directory {
id: string
name: string
files: File[] // Array of files
subdirectories: Directory[] // Self-reference for nested directories
parent: Directory // Self-reference for parent
}
✨ Edit in Studiotype Product {
id: string
name: string
price: number
categories: Category[] // Array of categories
relatedProducts: Product[] // Self-reference
reviews: Review[]
images: string[]
}
type Category {
id: string
name: string
products: Product[] // Back reference
subcategories: Category[] // Self-reference
}
type Review {
id: string
rating: number
comment: string
product: Product // Back reference
user: User
}
✨ Edit in StudioAexol validates:
[], [][], etc.)Before:
type User {
id: string
tagList: string
}
✨ Edit in StudioAfter:
type User {
id: string
tags: string[] // Now properly typed as array
}
✨ Edit in StudioBefore:
type Post {
id: string
authorId: string // Just an ID
}
✨ Edit in StudioAfter:
type Post {
id: string
author: User // Now a proper reference
}
type User {
id: string
posts: Post[] // Bidirectional relationship
}
✨ Edit in Studio