2022 • 50% for developing a Rails app, 50% for developing OSS (RBS) • Currently I'm working on updating Ruby 3.1 and introducing Steep to the Rails app. I joined Money Forward, inc!
ruby/rbs#905: Remove CharScanner due to no longer used • ruby/rbs#907: Reduce memory usage of RBS::Buffer • kpumuk/meta-tags#237: Separate RBS files to _internal directory to avoid exposing RBS • ruby/rbs#914: Accept Numeric by Integer#{upto,downto} • ruby/rbs#919: Fix bin/sort for constants • rbs/pull#921: Add manifest.yaml for rbs gem • ruby/rbs#926: Fix bin/sort (WIP) • pocke/rbs_rails#212: CI against Ruby 3.1 • pocke/rbs_rails#213: Bundle update to update rbs and steep • pocke/rbs_rails#214: Documentation update • pocke/rbs_rails#215: Fix spec • pocke/rbs_rails#216: Generate dependency types of relations • pocke/rbs_rails#217: Add rails generator to generate rbs.rake • pocke/rbs_rails#218: Do not expose polyfil RBSs My works
describe the structure of Ruby programs." ◦ https://github.com/ruby/rbs#rbs • Type Language for Ruby • RBS is available since Ruby 2.6 ◦ But I highly recommend Ruby 2.7+ RBS is …
Regexp pat, String rep) -> String end RBS Syntax See https://github.com/ruby/rbs/blob/master/docs/rbs_by_exa mple.md as a tutorial, https://github.com/ruby/rbs/blob/master/docs/syntax.md as a reference.
`gem install rbs` • Defines RBS language • Provides RBS loader for other tools • Provides tools to support using RBS • Contains core and stdlib's RBS files ruby/rbs
activesupport gem • Similar with DefinitelyTyped for TypeScript • Contributions are welcome! ◦ https://github.com/ruby/gem_rbs_collection/blob/main /docs/CONTRIBUTING.md ruby/gem_rbs_collection
◦ See my talk at RubyKaigi Takeout 2021 https://rubykaigi.org/2021-takeout/presentations/p_c k_.html • Run the following commands ◦ `rbs collection init` ◦ `rbs collection install` Setup rbs collection
Generating RBS ◦ Enhance RBS Rails ◦ Write more RBSs in gem_rbs_collection ◦ Support meta-programming in RBS • Introducing RBS to a team smoothly ◦ Run Steep on CI ◦ Improve performance ◦ Generating RBS "continuously" ◦ Share knowledge to team Issues
Generating RBS ◦ Enhance RBS Rails ◦ Write more RBSs in gem_rbs_collection ◦ Support meta-programming in RBS • Introducing RBS to a team smoothly ◦ Run Steep on CI ◦ Improve performance ◦ Generating RBS "continuously" ◦ Share knowledge to team Issues (again)
generate RBS ◦ `rbs prototype rb path/to/file.rb` • 👍 Easy to run, easy to guess what will be generated • 👎 Not good at meta-programming ◦ e.g. eval, define_method, etc... rbs prototype rb
extract method information with meta-programming ◦ `rbs prototype runtime KlassName` • 👍 Good at meta-programming • 👎 It may raise an error, generate dirty RBSs. • 👎 User needs to specify class name. rbs prototype runtime
good at meta programming • It may generate RBS does not work standalone ◦ e.g. on `class C < D`, it generates C but doesn't generate D. • We still get type errors even if it runs with generated RBSs • It is not aware of existing RBSs Problems
should be based on `prototype runtime` • To work standalone ◦ → Fix bugs, generate dependency types • To avoid type errors ◦ → Generate more lenient types • To be aware of existing RBSs ◦ `rbs subtract` may solve this issue Goals
this problem few days ago (Japanese). ◦ Rails + RBS & Steepを試してみて困ったところとか感想 とか - Qiita • e.g. different self in lambda ◦ validate :foobar, if: -> { new_record? } Support meta-programming
easily, but it still has many problems. • I'm working on generating RBS. It should generate RBSs that work out of the box. • Go to Hinase, Eat Kakioko🦪🦪🦪 Conclusion