Typelizer generates TypeScript types, route helpers, and OpenAPI schemas from your Ruby on Rails application. It keeps your backend and frontend in sync without hand-maintaining types.
- Automatic TypeScript interface generation from serializers
- Type-safe route helpers from Rails routes
- Supports Alba, ActiveModel::Serializer, Oj::Serializer, Panko::Serializer
- OpenAPI 3.0/3.1 schema generation
- Multiple output writers with layered configuration
- File watching with automatic regeneration in development
Add to your Gemfile:
gem "typelizer"Include the DSL in your serializers:
class ApplicationResource
include Alba::Resource
include Typelizer::DSL
end
class PostResource < ApplicationResource
attributes :id, :title, :body
endGenerate TypeScript types:
rails typelizer:generateFull documentation: https://typelizer.dev
You need PostgreSQL running locally. Then:
bundle install
cd spec/app && RAILS_ENV=test bundle exec rails db:create db:migrate && cd ../..
bundle exec rspecThe test suite uses a dummy Rails app in spec/app/ with models, migrations, and serializers for all four supported frameworks (Alba, AMS, OjSerializers, Panko). Linting is done with StandardRB:
bundle exec standardrbbundle exec rake runs both the tests and the linter.
Typelizer is inspired by types_from_serializers, js-routes, and Wayfinder.
The gem is available as open source under the terms of the MIT License.