Minimal Sorbet with inline RBS comments
I’ve been working through the fantastic Crafting Interpreters book, and implementing the Lox interpreter in Ruby. I wanted a minimal type checking setup for the code, so I decided to configure sorbet with RBS comment syntax.
First, we add the sorbet and tapioca gems to the Gemfile.
gem "sorbet"
gem "tapioca", require: false
Next, we add a sorbet/config file that includes all the arguments that we would pass when running the srb typecheck command:
--dir
lib
--enable-experimental-rbs-comments
And that’s basically it! You can now type check your Ruby codebase with bundle exec srb typecheck.
Based on my experience adding Sorbet to a Rails app in the past, I expected this to be more cumbersome. Having seen how straightforward it is to get started, I think sorbet is going to be part of even my smaller Ruby projects.