Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

t-ruby

> 编程语言
Open source

T-Ruby, TypeScript-style types for Ruby language

269 stars0 likes1 views
WebsiteGitHub

About

T-Ruby, TypeScript-style types for Ruby language

T-Ruby

TypeScript-style types for Ruby

Official Website

Install   •   Quick Start   •   Features   •   Roadmap   •   한국어   •   日本語

[!NOTE] This project is still experimental. If you support this project, please give it a star! If you have suggestions for improvements, please open an issue. Pull requests are also welcome!


What is T-Ruby?

T-Ruby is a typed layer for Ruby, inspired by TypeScript. It ships as a single executable called trc.

Write .trb files with type annotations, compile to standard .rb files. Types are erased at compile time — your Ruby code runs everywhere Ruby runs.

bash
trc hello.trb                  # Compile to Ruby

The trc compiler also generates .rbs signature files for tools like Steep and Ruby LSP. Gradually adopt types in existing Ruby projects with zero runtime overhead.

bash
trc --watch src/               # Watch mode
trc --emit-rbs src/            # Generate .rbs files
trc --check src/               # Type check without compiling

Why T-Ruby?

We are friends of Ruby — Rubyists who still use and love Ruby.

We know Ruby has duck typing and dynamic types in its DNA. But we couldn't ignore that static type systems are becoming essential in real-world production environments.

The Ruby ecosystem has debated this for years, yet hasn't quite found its answer.

Existing Approaches

1) Sorbet

  • Types are written like comments above your code.
  • It feels like writing JSDoc and hoping the IDE catches errors.
ruby
# Sorbet
extend T::Sig

sig { params(name: String).returns(String) }
def greet(name)
  "Hello, #{name}!"
end

2) RBS

  • Ruby's official approach, where .rbs files are separate type definition files like TypeScript's .d.ts.
  • But in Ruby, you have to write them manually or rely on "implicit inference + manual fixes" — still cumbersome.
rbs
# greet.rbs (separate file)
def greet: (String name) -> String
ruby
# greet.rb (no type info)
def greet(name)
  "Hello, #{name}!"
end

T-Ruby

  • Like TypeScript, types live inside your code.
  • Write .trb, and trc generates both .rb and .rbs.
trb
# greet.trb
def greet(name: String): String
  "Hello, #{name}!"
end
bash
trc greet.trb
# => build/greet.rb
#  + build/greet.rbs

Others...

There are new languages like Crystal, but strictly speaking, it's a different language from Ruby.

We still love Ruby, and we want this to be progress within the Ruby ecosystem, not an escape from it.


Install

bash
# with RubyGems (recommended)
gem install t-ruby

# from source
git clone https://github.com/type-ruby/t-ruby
cd t-ruby && bundle install

Verify installation

bash
trc --version

Quick start

1. Initialize project

bash
trc --init

This creates:

  • trbconfig.yml — project configuration
  • src/ — source directory
  • build/ — output directory

2. Write .trb

trb
# src/hello.trb
def greet(name: String): String
  "Hello, #{name}!"
end

puts greet("world")

3. Compile

bash
trc src/hello.trb

4. Run

bash
ruby build/hello.rb
# => Hello, world!

5. Watch mode

bash
trc -w           # Watch directories from trbconfig.yml (default: src/)
trc -w lib/      # Watch specific directory

Files are automatically recompiled on change.


Configuration

trc --init generates a trbconfig.yml file with all available options:

…

Features

  • Type annotations — Parameter and return types, erased at compile time
  • Union types — String | Integer | nil
  • Generics — User[], Array, Hash
  • Interfaces — Define contracts between objects
  • Type aliases — type UserID = Integer
  • RBS generation — Works with Steep, Ruby LSP, Sorbet
  • IDE support — VS Code, Neovim with LSP
  • Watch mode — Recompile on file changes

Links

IDE Support

  • VS Code Extension (and Cursor)
  • JetBrains Plugin
  • Vim / Neovim

Guides

  • Syntax Highlighting

Status

Experimental — T-Ruby is under active development. APIs may change. Not recommended for production use yet.

Milestone Status
Type Parsing & Erasure ✅
Core Type System ✅
LSP & IDE Support ✅
Advanced Features ✅

See ROADMAP.md for details.


Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

❤️ Support T-Ruby

If you find T-Ruby useful, consider sponsoring the project to support ongoing development and experimentation.

License

BSD 2-Clause

Issues· 9 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubycompilerprogramming-languagerubyt-ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言