Ruby T-Ruby, TypeScript-style types for Ruby language

mfb777 · January 21, 2026 · Last by hellorails replied at January 22, 2026 · 108 hits

https://type-ruby.github.io/

def greet(name: String): String
  "Hello, #{name}!"
end

编写带类型的 .trb 文件,编译生成 .rb 和 .rbs 文件。

Sorbet 太丑陋,rbs 文件又太繁琐。T-Ruby 这个方式个人感觉是比较优雅的,具体用起来有什么坑还不清楚,感觉问题不大。

对生态很好的补充。

你们职业生涯以来因为数据类型导致的 bugs 遇到过几例,我几乎没有这方面的记忆。 现在几乎也是 AI 写代码,估计现在 AI 也不习惯用 T-Ruby。

之前在 reddit 問過他怎麼處理 keyword arguments,他最終的方案還挺優雅的 https://type-ruby.github.io/docs/learn/functions/optional-rest-parameters#keyword-arguments

我想的是 crystal 转译 ruby

现在好了 直接改拓展名 .trb

类型这种 issue, 出现了就是很弱智,不应该。但是 Ruby 项目常常遇到

编译了个寂寞

You need to Sign in before reply, if you don't have an account, please Sign up first.