Skip to content

Release Note 3.1

Masataka Pocke Kuwabara edited this page May 2, 2023 · 4 revisions

Some of the highlights in RBS 3.1 are:

  • Add rbs subtract method (#1287)
  • Add more options to rbs parse command (#1252)

You can install it with $ gem install rbs or using Bundler.

gem 'rbs', '~> 3.1.0'

Read the CHANGELOG for the details.

There are no (intended) breaking changes in RBS 3.1. You can upgrade safely from 3.0 to 3.1.

Add rbs subtract method

rbs subtract deletes the duplicated definitions from RBS files. That helps working with both auto-generated signatures and manually-changed signatures. You will generate an RBS file with generators, like rbs prototype or rbs_rails, and will modify some of the declarations manually for precise type checking. Then you can use the rbs subtract to avoid re-generated definition breaks everything.

# Generate RBSs for Active Record models under sig/rbs_rails directory
$ bin/rake rbs_rails:all

# Generate RBSs for all Ruby code under sig/prototype directory
$ rbs prototype rb --out-dir=sig/prototype --base-dir=. app lib

# Remove methods generated by RBS Rails from sig/prototype
$ rbs subtract --write sig/prototype sig/rbs_rails
# Remove hand-written methods from generated RBSs
$ rbs subtract --write sig/prototype sig/rbs_rails sig/hand-written

See the spec for more detailed explanations.

Add more options to rbs parse command

You can test if a string is a correct RBS syntax with rbs parse with -e option without writing it to a file.

$ rbs parse -e 'class Foo end'
$ rbs parse --type -e 'Array[Integer]'
$ rbs parse --method-type -e '() { () [self: self] } -> void'