Overview
IlanaORM generates TypeScript types directly from your model files and migration definitions — no build step, no schema file, no manual maintenance. Each model gets:- A typed
Attributesinterface with the correct type per column (including enum union types) - A
declare classwith relation method signatures - A barrel
index.d.tsfor clean imports
Generating Types
types/ directory by default:
Custom output directory
Auto-generation on migrate
Types are regenerated automatically every time you run a migration:Example Output
Given this model and migration:Using the Generated Types
What Gets Inferred
| Source | What it generates |
|---|---|
Migration string, text | string |
Migration integer, float, decimal | number |
Migration boolean | boolean |
Migration date, datetime, timestamp | Date |
Migration json, jsonb | Record<string, any> |
Migration enum('col', ['a','b']) | 'a' | 'b' |
static casts = { col: 'json' } | Record<string, any> |
static casts = { col: 'array' } | any[] |
static casts = { col: 'boolean' } | boolean |
.nullable() in migration | Type | null |
static softDeletes = true | adds deleted_at?: Date | null |
| Relation methods | typed return (Post[], User | null, etc.) |
Notes
- Types are only generated for TypeScript projects (detected by the presence of
tsconfig.json) - The
types/directory should be added to.gitignore— regenerate it from migrations instead - Do not edit generated files — they will be overwritten on the next
migrateortypesrun - For custom cast classes, the column falls back to
any— add a manual override if needed
